ConcurrentEngineRetrieval_module.cc
Go to the documentation of this file.
1 //========================================================================
2 // ConcurrentEngineRetrieval
3 //
4 // This is module that is intended to test the parallel retrieval/use
5 // of a RandomNumberGenerator engine. Two tests are performed:
6 //
7 // (1) Create multiple distributions in the c'tor, but do not
8 // directly call RandomNumberGenerator::getEngine during the
9 // testing of the random-number-generator.
10 //
11 // (2) Create multiple distributions simultaneously be calling
12 // RandomNumberGenerator::getEngine in multiple threads.
13 // ========================================================================
14 
16 
24 #include "cetlib/test_macros.h"
25 
26 #include "CLHEP/Random/RandFlat.h"
27 
28 #include <algorithm>
29 #include <functional>
30 #include <vector>
31 
32 namespace art {
33  namespace test {
34 
36  public:
38  ProcessingFrame const&);
39 
40  private:
41  void analyze(art::Event const&, art::ProcessingFrame const&) override;
42  CLHEP::RandFlat dist_;
43  };
44 
46  fhicl::ParameterSet const& p,
47  ProcessingFrame const& frame)
48  : ReplicatedAnalyzer{p, frame}, dist_{createEngine(p.get<int>("seed"))}
49  {}
50 
51  void
53  art::ProcessingFrame const&)
54  {
55  std::vector<std::size_t> numbers(5);
56  std::size_t constexpr random_range{1000};
57  std::generate_n(numbers.begin(), numbers.size(), [this] {
58  return dist_.fireInt(random_range);
59  });
60  // Find way to verify this for all schedules?
61  }
62 
63  } // namespace test
64 } // namespace art
65 
base_engine_t & createEngine(seed_t seed)
Definition: test.py:1
ConcurrentEngineRetrieval(fhicl::ParameterSet const &p, ProcessingFrame const &)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
p
Definition: test.py:228
void analyze(art::Event const &, art::ProcessingFrame const &) override