SeedTestRegisterOnSubRun_module.cc
Go to the documentation of this file.
1 /**
2  * @file SeedTestRegisterOnSubRun_module.cc
3  * @brief Tests engine registration and query of seeds in beginSubRun() context.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date March 17, 2016
6  */
7 
8 
9 // art extensions
10 #include "nutools/RandomUtils/NuRandomService.h"
11 
12 // Supporting library include files
14 
15 // Framework includes.
21 
22 // forward declarations
23 namespace art { class SubRun; }
24 
25 
26 namespace testing {
27 
28  /**
29  * @brief Test module for NuRandomService
30  *
31  * The test tries to get a seed of an unknown engine during begin subrun.
32  *
33  * It is expected to fail, since the engine should be registered on
34  * construction.
35  *
36  * Note that the test does not actually get any random number.
37  *
38  * Configuration parameters: none
39  */
41 
42  public:
43 
44  explicit SeedTestRegisterOnSubRun(fhicl::ParameterSet const& pset);
45 
46  virtual void analyze(const art::Event&) override {}
47 
48 // void beginRun ( const art::Run& run) override;
49  virtual void beginSubRun(art::SubRun const&) override;
50 
51  }; // class SeedTestRegisterOnSubRun
52 
53 
54  SeedTestRegisterOnSubRun::SeedTestRegisterOnSubRun
55  (fhicl::ParameterSet const& pSet)
56  : art::EDAnalyzer(pSet)
57  {}
58 
59 
60  void SeedTestRegisterOnSubRun::beginSubRun(art::SubRun const&) {
61 
63  auto const seed = Seeds->getSeed(); // should throw
64 
65  mf::LogError("SeedTestRegisterOnSubRun")
66  << "Got seed=" << seed
67  << " for unregistered (unnamed) engine in beginSubRun(); should have thrown!";
68 
69  } // SeedTestRegisterOnSubRun::beginSubRun()
70 
71 } // namespace testing
72 
virtual void analyze(const art::Event &) override
seed_t getSeed(std::string instanceName)
Returns a seed for the engine with specified instance name.
LArSoft test utilities.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69