All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AtomicNumber.h
Go to the documentation of this file.
1 /**
2  * @file AtomicNumber.h
3  * @brief Provider returning atomic number of the active material in the TPC
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 13, 2016
6  * @see AtomicNumber.cxx AtomicNumberService.h
7  * @ingroup AtomicNumber
8  *
9  */
10 
11 #ifndef LAREXAMPLES_SERVICES_ATOMICNUMBER_PROVIDER_ATOMICNUMBER_H
12 #define LAREXAMPLES_SERVICES_ATOMICNUMBER_PROVIDER_ATOMICNUMBER_H
13 
14 
15 // support libraries
16 namespace fhicl { class ParameterSet; }
17 
18 #include "fhiclcpp/types/Atom.h"
19 #include "fhiclcpp/types/Comment.h"
20 #include "fhiclcpp/types/Name.h"
21 #include "fhiclcpp/types/Table.h"
22 
23 
24 namespace lar {
25  namespace example {
26 
27  /** **********************************************************************
28  * @brief Provides information about the active material in the TPC.
29  * @see @ref AtomicNumber "AtomicNumber example overview"
30  * @ingroup AtomicNumber
31  *
32  * Configuration parameters
33  * =========================
34  *
35  * See `AtomicNumber` service provider class.
36  *
37  * - *AtomicNumber* (integer, default: 18): atomic number of the active
38  * material
39  *
40  */
41  class AtomicNumber {
42  public:
43  //---------------------------------------------------------------------
44  /// Collection of configuration parameters for the service
45  struct Config {
46  using Name = fhicl::Name;
47  using Comment = fhicl::Comment;
48 
49  fhicl::Atom<unsigned int> AtomicNumber {
50  Name("AtomicNumber"),
51  Comment("atomic number of the active material in the TPC"),
52  18U // default value
53  };
54 
55  }; // struct Config
56 
57  /// Type describing all the parameters
58  using parameters_type = fhicl::Table<Config>;
59 
60 
61  //---------------------------------------------------------------------
62  /// Constructor from the complete configuration object
63  AtomicNumber(Config const& config)
64  : Z_(config.AtomicNumber())
65  {}
66 
67  //---------------------------------------------------------------------
68  /// Constructor from a parameter set
69  AtomicNumber(fhicl::ParameterSet const& pset)
70  : AtomicNumber(parameters_type(pset, { "service_type" })())
71  {}
72 
73 
74  //---------------------------------------------------------------------
75  // copy and moving of service providers is "forbidden":
76  AtomicNumber(AtomicNumber const& pset) = delete;
77  AtomicNumber(AtomicNumber&& pset) = delete;
78  AtomicNumber& operator= (AtomicNumber const& pset) = delete;
79  AtomicNumber& operator= (AtomicNumber&& pset) = delete;
80 
81 
82  //---------------------------------------------------------------------
83  /// @name Accessors
84  /// @{
85 
86  /// Returns the atomic number
87  unsigned int Z() const { return Z_; }
88 
89  /// @}
90 
91 
92  //---------------------------------------------------------------------
93  private:
94  unsigned int Z_; ///< atomic number
95 
96  }; // AtomicNumber
97 
98  } // namespace example
99 } // namespace lar
100 
101 
102 #endif // LAREXAMPLES_SERVICES_ATOMICNUMBER_PROVIDER_ATOMICNUMBER_H
fhicl::Table< Config > parameters_type
Type describing all the parameters.
Definition: AtomicNumber.h:58
Collection of configuration parameters for the service.
Definition: AtomicNumber.h:45
unsigned int Z() const
Returns the atomic number.
Definition: AtomicNumber.h:87
AtomicNumber(fhicl::ParameterSet const &pset)
Constructor from a parameter set.
Definition: AtomicNumber.h:69
BEGIN_PROLOG vertical distance to the surface Name
Provides information about the active material in the TPC.
Definition: AtomicNumber.h:41
unsigned int Z_
atomic number
Definition: AtomicNumber.h:94
AtomicNumber(Config const &config)
Constructor from the complete configuration object.
Definition: AtomicNumber.h:63
AtomicNumber & operator=(AtomicNumber const &pset)=delete