Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
arttest::RandomNumberSaveTest Class Reference
Inheritance diagram for arttest::RandomNumberSaveTest:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

using prod_t = std::vector< size_t >
 
using Parameters = Table< Config >
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 RandomNumberSaveTest (Parameters const &p)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer ()=default
 
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer ()
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
virtual ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

std::string const myLabel_
 
CLHEP::RandFlat dist_
 
size_t const dieOnNthEvent_
 
size_t eventN_ {}
 
bool const genUnsaved_
 

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 

Detailed Description

Definition at line 39 of file RandomNumberSaveTest_module.cc.

Member Typedef Documentation

Definition at line 48 of file RandomNumberSaveTest_module.cc.

using arttest::RandomNumberSaveTest::prod_t = std::vector<size_t>

Definition at line 41 of file RandomNumberSaveTest_module.cc.

Constructor & Destructor Documentation

arttest::RandomNumberSaveTest::RandomNumberSaveTest ( Parameters const &  p)
explicit

Definition at line 71 of file RandomNumberSaveTest_module.cc.

72  : EDProducer{p}
73  , myLabel_{p.get_PSet().get<std::string>("module_label")}
74  , dist_{createEngine(p().seed())}
75  , dieOnNthEvent_{p().dieOnNthEvent()}
76  , genUnsaved_{p().genUnsaved()}
77 {
78  produces<prod_t>();
79 }
base_engine_t & createEngine(seed_t seed)
std::string string
Definition: nybbler.cc:12
EDProducer()=default
p
Definition: test.py:228

Member Function Documentation

void arttest::RandomNumberSaveTest::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 82 of file RandomNumberSaveTest_module.cc.

83 {
84  if (++eventN_ == dieOnNthEvent_) {
86  << "Throwing while processing ordinal event " << eventN_
87  << " as requested.\n";
88  }
90  prod_t nums;
91  static size_t constexpr nums_size{5};
92  static size_t constexpr random_range{1000};
93  nums.reserve(nums_size);
94  generate_n(std::back_inserter(nums), nums_size, [this] {
95  return dist_.fireInt(random_range);
96  });
97  std::cerr << "nums: " << nums << "\n";
98  if (e.getByLabel(myLabel_, hp)) {
99  std::cerr << "(*hp): " << *hp << "\n";
100  // Reading.
101  BOOST_REQUIRE((*hp) == nums);
102  if (genUnsaved_) {
103  // Intentionally attempt to throw the sequence off for the next event.
104  dist_.fireInt(random_range);
105  }
106  } else {
107  // Writing.
108  e.put(std::make_unique<prod_t>(nums));
109  }
110 }
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:435
BOOST_REQUIRE(inFile)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692

Member Data Documentation

size_t const arttest::RandomNumberSaveTest::dieOnNthEvent_
private

Definition at line 56 of file RandomNumberSaveTest_module.cc.

CLHEP::RandFlat arttest::RandomNumberSaveTest::dist_
private

Definition at line 55 of file RandomNumberSaveTest_module.cc.

size_t arttest::RandomNumberSaveTest::eventN_ {}
private

Definition at line 57 of file RandomNumberSaveTest_module.cc.

bool const arttest::RandomNumberSaveTest::genUnsaved_
private

Definition at line 58 of file RandomNumberSaveTest_module.cc.

std::string const arttest::RandomNumberSaveTest::myLabel_
private

Definition at line 54 of file RandomNumberSaveTest_module.cc.


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