SeedTestRegisterOnProcessEvent_module.cc
Go to the documentation of this file.
1 /**
2  * @file SeedTestRegisterOnProcessEvent_module.cc
3  * @brief Tests engine registration and query of seeds in analyze() 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 // framework libraries
17 
18 // supporting libraries
20 
21 
22 // forward declarations
23 namespace art { class Event; }
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 event processing.
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 
45 
46  virtual void analyze(art::Event const&) override;
47 
48  }; // class SeedTestRegisterOnProcessEvent
49 
50 
51  SeedTestRegisterOnProcessEvent::SeedTestRegisterOnProcessEvent
52  (fhicl::ParameterSet const& pset)
53  : art::EDAnalyzer(pset)
54  {}
55 
57 
59  auto const seed = Seeds->getSeed(); // should throw
60 
61  mf::LogError("SeedTestRegisterOnProcessEvent")
62  << "Got seed=" << seed
63  << " for unregistered (unnamed) engine in analyze(); should have thrown!";
64 
65  } // SeedTestRegisterOnProcessEvent::analyze()
66 
67 } // end namespace testing
68 
def analyze(root, level, gtrees, gbranches, doprint)
Definition: rootstat.py:67
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
Definition: types.h:32