LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
rndm::details::LinearMappingPolicy< SEED > Class Template Reference

Implementation of the "linearMapping" policy. More...

#include "BasePolicies.h"

Inheritance diagram for rndm::details::LinearMappingPolicy< 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 >

Public Types

using base_t = CheckedRangePolicy< SEED >
 
using this_t = LinearMappingPolicy< SEED >
 
using seed_t = typename base_t::seed_t
 
using base_t = CheckedRangePolicy< SEED >
 
using this_t = LinearMappingPolicy< SEED >
 
using seed_t = typename base_t::seed_t
 
using EventData_t = NuRandomServiceHelper::EventSeedInputData
 type of data used for event seeds More...
 
using EventData_t = NuRandomServiceHelper::EventSeedInputData
 type of data used for event seeds More...
 

Public Member Functions

 LinearMappingPolicy (fhicl::ParameterSet const &pset)
 
virtual void configure (fhicl::ParameterSet const &pset) override
 Configure this policy. More...
 
virtual void print (std::ostream &out) const override
 Prints the configuration of this policy. More...
 
 LinearMappingPolicy (fhicl::ParameterSet const &pset)
 
virtual void configure (fhicl::ParameterSet const &pset) override
 Configure this policy. More...
 
virtual void print (std::ostream &out) const override
 Prints the configuration of this policy. More...
 
virtual seed_t getSeed (SeedMasterHelper::EngineId const &id)
 Returns the next random number. More...
 
virtual seed_t getSeed (SeedMasterHelper::EngineId const &id) override
 Returns the next random number. More...
 
virtual seed_t getEventSeed (SeedMasterHelper::EngineId const &id, EventData_t const &eventInfo)
 Returns a random number specific to an event. More...
 
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...
 
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...
 
virtual bool yieldsUniqueSeeds () const
 Returns whether the returned seed should be unique. More...
 

Static Public Attributes

static constexpr seed_t InvalidSeed = 0
 An invalid seed. More...
 

Protected Member Functions

virtual seed_t createSeed (SeedMasterHelper::EngineId const &) override
 Returns the next random number. More...
 
void static_configure (fhicl::ParameterSet const &pset)
 
virtual seed_t createSeed (SeedMasterHelper::EngineId const &) override
 Returns the next random number. More...
 
void static_configure (fhicl::ParameterSet const &pset)
 
virtual void ensureRange (SeedMasterHelper::EngineId const &id, seed_t seed) const
 Performs the range checks and complains if needed. 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 CheckRangeConfiguration () const
 Check that the configuration is complete. More...
 
virtual seed_t createEventSeed (SeedMasterHelper::EngineId const &, EventData_t const &)
 Extracts a seed for specified event information; returns InvalidSeed. More...
 
virtual seed_t createEventSeed (SeedMasterHelper::EngineId const &, EventData_t const &)
 Extracts a seed for specified event information; returns InvalidSeed. More...
 

Protected Attributes

seed_t first_seed
 base seed More...
 
seed_t next_seed
 next seed delivered More...
 
unsigned int nSeedsPerJob
 
RangeCheckHelper< seed_trange_check
 
std::string name
 name of the policy More...
 

Detailed Description

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

Implementation of the "linearMapping" policy.


See also
CheckedRangePolicy

This is heavily based on CheckedRangePolicy.

Definition at line 415 of file BasePolicies.h.

Member Typedef Documentation

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

Definition at line 114 of file StandardPolicies.h.

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

Definition at line 417 of file BasePolicies.h.

type of data used for event seeds

Definition at line 48 of file BasePolicies.h.

type of data used for event seeds

Definition at line 93 of file RandomSeedPolicyBase.h.

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

Definition at line 116 of file StandardPolicies.h.

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

Definition at line 419 of file BasePolicies.h.

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

Definition at line 115 of file StandardPolicies.h.

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

Definition at line 418 of file BasePolicies.h.

Constructor & Destructor Documentation

template<typename SEED >
rndm::details::LinearMappingPolicy< SEED >::LinearMappingPolicy ( fhicl::ParameterSet const &  pset)
inline

Configures from a parameter set

See also
configure()

Definition at line 423 of file BasePolicies.h.

423  :
424  base_t("linearMapping")
425  { this_t::configure(pset); }
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:439
CheckedRangePolicy< SEED > base_t
Definition: BasePolicies.h:417
template<typename SEED >
rndm::details::LinearMappingPolicy< SEED >::LinearMappingPolicy ( fhicl::ParameterSet const &  pset)
inline

Configures from a parameter set

See also
configure()

Definition at line 120 of file StandardPolicies.h.

References rndm::details::AutoIncrementPolicy< SEED >::configure().

120  :
121  base_t("linearMapping")
122  { this_t::configure(pset); }
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:439
CheckedRangePolicy< SEED > base_t
Definition: BasePolicies.h:417

Member Function Documentation

template<typename SEED >
void rndm::details::CheckedRangePolicy< SEED >::CheckRangeConfiguration ( ) const
protectedinherited

Check that the configuration is complete.

Definition at line 323 of file BasePolicies.h.

References art::errors::Configuration, rndm::details::RandomSeedPolicyBase< SEED >::getName(), rndm::details::RangeCheckHelper< SEED >::isConfigured(), and rndm::details::RangeCheckHelper< SEED >::missingConfig().

Referenced by rndm::details::AutoIncrementPolicy< SEED >::createSeed(), rndm::details::LinearMappingPolicy< SEED >::createSeed(), rndm::details::PredefinedOffsetPolicy< SEED >::createSeed(), and rndm::details::CheckedRangePolicy< SEED >::ensureRange().

323  {
324  if (!range_check.isConfigured()) {
325  std::ostringstream sstr;
326  sstr << "configuration of policy '" << this->getName()
327  << "' incomplete:";
328  for (std::string const& name: range_check.missingConfig())
329  sstr << " " << name;
330  throw art::Exception(art::errors::Configuration) << sstr.str();
331  }
332  } // CheckedRangePolicy<SEED>::CheckRangeConfiguration()
std::vector< std::string > missingConfig() const
Returns the items currently not configured.
Definition: BasePolicies.h:242
bool isConfigured() const
Returns whether all the parameters are configured.
Definition: BasePolicies.h:208
std::string name
name of the policy
Definition: BasePolicies.h:83
RangeCheckHelper< seed_t > range_check
Definition: BasePolicies.h:296
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string getName() const
Returns the given name of the policy.
Definition: BasePolicies.h:73
template<typename SEED >
void rndm::details::CheckedRangePolicy< SEED >::CheckRangeConfiguration ( ) const
protectedinherited

Check that the configuration is complete.

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

Configure this policy.

Parameters
psetthe parameter set for the configuration

Parameters:

  • nJob (unsigned integer): the number of this job; the first seed
  • checkRange (boolean, default: true): whether to verify that each seed is within the expected range
  • maxUniqueEngines (unsigned integer, mandatory) the maximum number on seeds we expect to create

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

Definition at line 136 of file StandardPolicies.h.

References rndm::details::CheckedRangePolicy< SEED >::configure(), rndm::details::AutoIncrementPolicy< SEED >::first_seed, rndm::details::AutoIncrementPolicy< SEED >::next_seed, rndm::details::AutoIncrementPolicy< SEED >::print(), rndm::details::CheckedRangePolicy< SEED >::range_check, rndm::details::RangeCheckHelper< SEED >::SetConfigLabels(), and rndm::details::AutoIncrementPolicy< SEED >::static_configure().

137  {
138  base_t::range_check.SetConfigLabels("", "", "checkRange");
139  base_t::configure(pset);
140  static_configure(pset);
141  }
void static_configure(fhicl::ParameterSet const &pset)
Definition: BasePolicies.h:465
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:277
RangeCheckHelper< seed_t > range_check
Definition: BasePolicies.h:296
void SetConfigLabels(std::string maxSeedsLabel="maxUniqueEngines", std::string baseSeedLabel="baseSeed", std::string checkRangeLabel="checkRange")
Definition: BasePolicies.h:177
template<typename SEED >
virtual void rndm::details::LinearMappingPolicy< SEED >::configure ( fhicl::ParameterSet const &  pset)
inlineoverridevirtual

Configure this policy.

Parameters
psetthe parameter set for the configuration

Parameters:

  • nJob (unsigned integer): the number of this job; the first seed
  • checkRange (boolean, default: true): whether to verify that each seed is within the expected range
  • maxUniqueEngines (unsigned integer, mandatory) the maximum number on seeds we expect to create

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

Definition at line 439 of file BasePolicies.h.

References rndm::details::RandomSeedPolicyBase< SEED >::print().

440  {
441  base_t::range_check.SetConfigLabels("", "", "checkRange");
442  base_t::configure(pset);
443  static_configure(pset);
444  }
void static_configure(fhicl::ParameterSet const &pset)
Definition: BasePolicies.h:465
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:277
RangeCheckHelper< seed_t > range_check
Definition: BasePolicies.h:296
void SetConfigLabels(std::string maxSeedsLabel="maxUniqueEngines", std::string baseSeedLabel="baseSeed", std::string checkRangeLabel="checkRange")
Definition: BasePolicies.h:177
template<typename SEED>
virtual seed_t rndm::details::RandomSeedPolicyBase< SEED >::createEventSeed ( SeedMasterHelper::EngineId const &  ,
EventData_t const &   
)
inlineprotectedvirtualinherited

Extracts a seed for specified event information; returns InvalidSeed.

Reimplemented in rndm::details::PerEventPolicy< SEED >.

Definition at line 90 of file BasePolicies.h.

References rndm::details::RandomSeedPolicyBase< SEED >::InvalidSeed.

Referenced by rndm::details::RandomSeedPolicyBase< SEED >::getEventSeed().

91  { return InvalidSeed; }
static constexpr seed_t InvalidSeed
An invalid seed.
Definition: BasePolicies.h:51
template<typename SEED>
virtual seed_t rndm::details::RandomSeedPolicyBase< SEED >::createEventSeed ( SeedMasterHelper::EngineId const &  ,
EventData_t const &   
)
inlineprotectedvirtualinherited

Extracts a seed for specified event information; returns InvalidSeed.

Reimplemented in rndm::details::PerEventPolicy< SEED >.

Definition at line 135 of file RandomSeedPolicyBase.h.

136  { return InvalidSeed; }
static constexpr seed_t InvalidSeed
An invalid seed.
Definition: BasePolicies.h:51
template<typename SEED >
virtual seed_t rndm::details::LinearMappingPolicy< SEED >::createSeed ( SeedMasterHelper::EngineId const &  )
inlineoverrideprotectedvirtual

Returns the next random number.

Implements rndm::details::RandomSeedPolicyBase< SEED >.

Definition at line 455 of file BasePolicies.h.

References rndm::details::LinearMappingPolicy< SEED >::static_configure().

456  { return next_seed++; }
seed_t next_seed
next seed delivered
Definition: BasePolicies.h:451
template<typename SEED >
virtual void rndm::details::CheckedRangePolicy< SEED >::ensureRange ( SeedMasterHelper::EngineId const &  id,
seed_t  seed 
) const
inlineprotectedvirtualinherited

Performs the range checks and complains if needed.

Definition at line 303 of file BasePolicies.h.

References rndm::details::RangeCheckHelper< SEED >::EnsureRange(), rndm::details::RandomSeedPolicyBase< SEED >::getName(), and rndm::details::CheckedRangePolicy< SEED >::static_configure().

304  { range_check.EnsureRange(this->getName(), id, seed); }
long seed
Definition: chem4.cc:68
RangeCheckHelper< seed_t > range_check
Definition: BasePolicies.h:296
void EnsureRange(std::string policy, SeedMasterHelper::EngineId const &id, seed_t seed) const
Throws an exception if the range check on seed fails.
Definition: BasePolicies.h:214
std::string getName() const
Returns the given name of the policy.
Definition: BasePolicies.h:73
template<typename SEED >
virtual void rndm::details::CheckedRangePolicy< SEED >::ensureRange ( SeedMasterHelper::EngineId const &  id,
seed_t  seed 
) const
inlineprotectedvirtualinherited

Performs the range checks and complains if needed.

Definition at line 348 of file RandomSeedPolicyBase.h.

References rndm::details::CheckedRangePolicy< SEED >::CheckRangeConfiguration(), art::errors::Configuration, rndm::details::RangeCheckHelper< SEED >::configure(), rndm::details::RangeCheckHelper< SEED >::EnsureRange(), rndm::details::RangeCheckHelper< SEED >::isConfigured(), rndm::details::RangeCheckHelper< SEED >::missingConfig(), and rndm::details::CheckedRangePolicy< SEED >::static_configure().

349  { range_check.EnsureRange(this->getName(), id, seed); }
long seed
Definition: chem4.cc:68
RangeCheckHelper< seed_t > range_check
Definition: BasePolicies.h:296
void EnsureRange(std::string policy, SeedMasterHelper::EngineId const &id, seed_t seed) const
Throws an exception if the range check on seed fails.
Definition: BasePolicies.h:214
std::string getName() const
Returns the given name of the policy.
Definition: BasePolicies.h:73
template<typename SEED>
virtual seed_t rndm::details::RandomSeedPolicyBase< SEED >::getEventSeed ( SeedMasterHelper::EngineId const &  id,
EventData_t const &  eventInfo 
)
inlinevirtualinherited

Returns a random number specific to an event.

Definition at line 69 of file BasePolicies.h.

References rndm::details::RandomSeedPolicyBase< SEED >::createEventSeed().

Referenced by rndm::details::RandomSeedPolicyBase< SEED >::getSeed().

70  { return createEventSeed(id, eventInfo); }
virtual seed_t createEventSeed(SeedMasterHelper::EngineId const &, EventData_t const &)
Extracts a seed for specified event information; returns InvalidSeed.
Definition: BasePolicies.h:90
template<typename SEED>
virtual seed_t rndm::details::RandomSeedPolicyBase< SEED >::getEventSeed ( SeedMasterHelper::EngineId const &  id,
EventData_t const &  eventInfo 
)
inlinevirtualinherited

Returns a random number specific to an event.

Definition at line 114 of file RandomSeedPolicyBase.h.

115  { return createEventSeed(id, eventInfo); }
virtual seed_t createEventSeed(SeedMasterHelper::EngineId const &, EventData_t const &)
Extracts a seed for specified event information; returns InvalidSeed.
Definition: BasePolicies.h:90
template<typename SEED>
std::string rndm::details::RandomSeedPolicyBase< SEED >::getName ( ) const
inlineinherited
template<typename SEED>
std::string rndm::details::RandomSeedPolicyBase< SEED >::getName ( ) const
inlineinherited

Returns the given name of the policy.

Definition at line 118 of file RandomSeedPolicyBase.h.

118 { return name; }
std::string name
name of the policy
Definition: BasePolicies.h:83
template<typename SEED >
virtual seed_t rndm::details::CheckedRangePolicy< SEED >::getSeed ( SeedMasterHelper::EngineId const &  id)
inlinevirtualinherited

Returns the next random number.

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

Definition at line 281 of file BasePolicies.h.

References rndm::details::RandomSeedPolicyBase< SEED >::createSeed(), and seed.

282  {
283  seed_t seed = this->createSeed(id);
284  ensureRange(id, seed);
285  return seed;
286  } // getSeed()
typename base_t::seed_t seed_t
Definition: BasePolicies.h:258
virtual seed_t createSeed(SeedMasterHelper::EngineId const &)=0
Extracts the next random number seed.
long seed
Definition: chem4.cc:68
virtual void ensureRange(SeedMasterHelper::EngineId const &id, seed_t seed) const
Performs the range checks and complains if needed.
Definition: BasePolicies.h:303
template<typename SEED >
virtual seed_t rndm::details::CheckedRangePolicy< SEED >::getSeed ( SeedMasterHelper::EngineId const &  id)
inlineoverridevirtualinherited

Returns the next random number.

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

Definition at line 326 of file RandomSeedPolicyBase.h.

References rndm::details::ValidSeed< SEED >::seed.

327  {
328  seed_t seed = this->createSeed(id);
329  ensureRange(id, seed);
330  return seed;
331  } // getSeed()
typename base_t::seed_t seed_t
Definition: BasePolicies.h:258
virtual seed_t createSeed(SeedMasterHelper::EngineId const &)=0
Extracts the next random number seed.
long seed
Definition: chem4.cc:68
virtual void ensureRange(SeedMasterHelper::EngineId const &id, seed_t seed) const
Performs the range checks and complains if needed.
Definition: BasePolicies.h:303
template<typename SEED >
virtual void rndm::details::LinearMappingPolicy< SEED >::print ( std::ostream &  out) const
overridevirtual

Prints the configuration of this policy.

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

template<typename SEED >
void rndm::details::LinearMappingPolicy< SEED >::print ( std::ostream &  out) const
overridevirtual

Prints the configuration of this policy.

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

Definition at line 495 of file BasePolicies.h.

Referenced by rndm::details::LinearMappingPolicy< SEED >::createSeed().

495  {
496  base_t::print(out);
497  out
498  << "\n first seed: " << first_seed
499  << "\n seeds per job: " << nSeedsPerJob;
500  } // LinearMappingPolicy<SEED>::print()
virtual void print(std::ostream &out) const override
Prints information on the configuration of this policy.
Definition: BasePolicies.h:289
template<typename SEED >
void rndm::details::LinearMappingPolicy< SEED >::static_configure ( fhicl::ParameterSet const &  pset)
protected
template<typename SEED >
void rndm::details::LinearMappingPolicy< SEED >::static_configure ( fhicl::ParameterSet const &  pset)
protected

Definition at line 465 of file BasePolicies.h.

References fhicl::ParameterSet::get(), and fhicl::ParameterSet::get_if_present().

Referenced by rndm::details::LinearMappingPolicy< SEED >::createSeed().

466  {
467  // this code is for legacy support, and it could disappear in the future
468  if (!pset.get_if_present<seed_t>("nJob", first_seed)) {
469  if (!pset.get_if_present<seed_t>("baseSeed", first_seed)) {
470  // this is going to fail; I am doing this just to get
471  // the more appropriate error message possible
472  first_seed = pset.get<seed_t>("nJob");
473  }
474  else {
475  mf::LogWarning("SeedMaster") <<
476  std::string(80, '*') <<
477  "\nDEPRECATION WARNING: 'baseSeed' parameter has been deprecated"
478  " for linearMapping policy, in favour of 'nJob'."
479  "\nPlease update your configuration accordingly."
480  << "\n" << std::string(80, '*');
481  }
482  }
483  // first_seed = pset.get<seed_t>("nJob");
484  nSeedsPerJob = pset.get<seed_t>("maxUniqueEngines");
486  ++first_seed; // we don't want 0 as a seed
491  } // LinearMappingPolicy<SEED>::configure()
seed_t next_seed
next seed delivered
Definition: BasePolicies.h:451
void SetNSeeds(seed_t nSeeds)
Sets the number of seeds directly.
Definition: BasePolicies.h:132
RangeCheckHelper< seed_t > range_check
Definition: BasePolicies.h:296
typename base_t::seed_t seed_t
Definition: BasePolicies.h:419
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void SetBaseSeed(seed_t base_seed)
Sets the base seed directly.
Definition: BasePolicies.h:128
void CheckRangeConfiguration() const
Check that the configuration is complete.
Definition: BasePolicies.h:323
template<typename SEED>
virtual bool rndm::details::RandomSeedPolicyBase< SEED >::yieldsUniqueSeeds ( ) const
inlineoverridevirtualinherited

Returns whether the returned seed should be unique.

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

Definition at line 80 of file BasePolicies.h.

80 { return true; }
template<typename SEED>
virtual bool rndm::details::RandomSeedPolicyBase< SEED >::yieldsUniqueSeeds ( ) const
inlinevirtualinherited

Returns whether the returned seed should be unique.

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

Definition at line 125 of file RandomSeedPolicyBase.h.

125 { return true; }

Member Data Documentation

template<typename SEED >
seed_t rndm::details::LinearMappingPolicy< SEED >::first_seed
protected

base seed

Definition at line 450 of file BasePolicies.h.

template<typename SEED>
static constexpr seed_t rndm::details::RandomSeedPolicyBase< SEED >::InvalidSeed = 0
staticinherited
template<typename SEED>
std::string rndm::details::RandomSeedPolicyBase< SEED >::name
protectedinherited

name of the policy

Definition at line 83 of file BasePolicies.h.

Referenced by rndm::details::RandomSeedPolicyBase< SEED >::getName().

template<typename SEED >
seed_t rndm::details::LinearMappingPolicy< SEED >::next_seed
protected

next seed delivered

Definition at line 451 of file BasePolicies.h.

template<typename SEED >
unsigned int rndm::details::LinearMappingPolicy< SEED >::nSeedsPerJob
protected

Definition at line 452 of file BasePolicies.h.


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