AtomicNumberTest_module.cc
Go to the documentation of this file.
1 /**
2  * @file AtomicNumberTest_module.cc
3  * @brief A simple test for AtomicNumberService example service
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 14, 2016
6  * @see AtomicNumberService.h
7  *
8  */
9 
10 // LArSoft libraries
13 
14 // framework and support libraries
15 #include "fhiclcpp/ParameterSet.h"
19 
20 
21 namespace lar {
22  namespace example {
23  namespace tests {
24 
25  /**
26  * @brief Tests AtomicNumberService
27  *
28  * Configuration parameters
29  * -------------------------
30  *
31  * - *AtomicNumber* (unsigned integer, mandatory): the expected atomic
32  * number
33  *
34  */
36  public:
37 
38  explicit AtomicNumberTest(fhicl::ParameterSet const& pset);
39 
40  /// We don't really care about events
41  virtual void analyze(art::Event const&) override {}
42 
43  /// Test happens at begin job
44  virtual void beginJob() override;
45 
46  private:
47 
48  unsigned int expected_Z; ///< expected atomic number
49 
50  }; // class AtomicNumberTest
51 
52  } // namespace tests
53  } // namespace example
54 } // namespace lar
55 
56 
57 
58 //------------------------------------------------------------------------------
59 
61  (fhicl::ParameterSet const& pset)
62  : art::EDAnalyzer(pset)
63  , expected_Z(pset.get<unsigned int>("AtomicNumber"))
64 {}
65 
66 
68 
69  auto const* Zprov = lar::providerFrom<lar::example::AtomicNumberService>();
70 
71  unsigned int const Z = Zprov->Z();
72  if (Z != expected_Z) {
74  << "Unexpected atomic number " << Z << ", should be " << expected_Z;
75  }
76 
77 } // lar::example::tests::AtomicNumberTest::beginJob()
78 
79 
80 
Provider returning atomic number of the active material in the TPC.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
T get(std::string const &key) const
Definition: ParameterSet.h:271
unsigned int expected_Z
expected atomic number
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
AtomicNumberTest(fhicl::ParameterSet const &pset)
LArSoft-specific namespace.
Returns the atomic number of the active material in the TPC.
virtual void analyze(art::Event const &) override
We don&#39;t really care about events.
virtual void beginJob() override
Test happens at begin job.