readout_types_fhicl.h
Go to the documentation of this file.
1 /**
2  * @file larcoreobj/SimpleTypesAndConstants/readout_types_fhicl.h
3  * @brief Utilities for using readout IDs in FHiCL validated configuration.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date November 26, 2019
6  *
7  * This library is header-only.
8  */
9 
10 #ifndef LARCOREOBJ_SIMPLETYPESANDCONSTANTS_READOUT_TYPES_FHICL_H
11 #define LARCOREOBJ_SIMPLETYPESANDCONSTANTS_READOUT_TYPES_FHICL_H
12 
13 
14 // LArSoft libraries
17 
18 // support libraries
19 #include "fhiclcpp/types/Atom.h"
20 
21 
22 namespace geo::fhicl {
23 
24  /// Configuration structure for validated `readout::TPCsetID` parameter.
25  template <>
26  struct IDConfig<readout::TPCsetID>: public IDConfig<readout::CryostatID> {
27  using ID_t = readout::TPCsetID; ///< Type read by this configuration.
28 
30  ::fhicl::Name("S"),
31  ::fhicl::Comment("TPC set number within the cryostat"),
32  [this](){ return valid(); }
33  };
34 
35  ID_t ID() const
36  { return !valid()? ID_t{}: ID_t{ IDConfig<readout::CryostatID>::ID(), S() }; }
37  operator ID_t() const { return ID(); }
38  }; // struct IDConfig<readout::TPCsetID>
39 
40 
41  /// Configuration structure for validated `readout::ROPID` parameter.
42  template <>
43  struct IDConfig<readout::ROPID>: public IDConfig<readout::TPCsetID> {
44  using ID_t = readout::ROPID; ///< Type read by this configuration.
45 
47  ::fhicl::Name("R"),
48  ::fhicl::Comment("Readout plane number within the TPC set"),
49  [this](){ return valid(); }
50  };
51 
52  ID_t ID() const
53  { return !valid()? ID_t{}: ID_t{ IDConfig<readout::TPCsetID>::ID(), R() }; }
54  operator ID_t() const { return ID(); }
55  }; // struct IDConfig<readout::ROPID>
56 
57 } // namespace geo::fhicl
58 
59 
60 /// FHiCL objects representing geometry classes as configuration parameters.
61 namespace readout::fhicl {
62 
63  // --- BEGIN -- Importing from geo::fhicl namespace --------------------------
64 
65  //
66  // types
67  //
69  using geo::fhicl::IDof;
75 
76  //
77  // utilities
78  //
79  using geo::fhicl::readID;
84 
85  // --- END -- Importing from geo::fhicl namespace ----------------------------
86 
87 
88  // --- BEGIN -- Validated configuration parameters for readout ID objects ----
89  /**
90  * @name Validated configuration parameters for readout ID objects
91  *
92  * These data types can be used in a class for validated FHiCL configuration.
93  * They are implemented as configuration tables (`fhicl::Table`) of a
94  * configuration structure containing one parameter (`fhicl::Atom`) per index
95  * in the ID. They do _not_ support default values, but optional parameters
96  * may be used as a workaround.
97  *
98  * These objects have the same type of implementation and follow the same
99  * usage patterns as the ones for geometry ID objects defined and documented
100  * in `geo::fhicl` namespace.
101  *
102  * This namespace offers:
103  * * a set of `readout` aliases, e.g. `readout::fhicl::CryostatID`, for
104  * cryostat IDs;
105  * * a set of classes for TPC set parameters, characterized by a configuration
106  * like `{ C:0 S:1 }`;
107  * * a set of classes for readout plane parameters, characterized by a
108  * configuration like `{ C:0 S:1 R:2 }`;
109  * * _no facility for `raw::ChannelID_t`_, which is a regular type and can be
110  * directly read with the standard `fhicl` objects.
111  *
112  */
113  /// @{
114 
115  // --- BEGIN -- Cryostat ID --------------------------------------------------
116  //
117  // because `readout::CryostatID` is an alias of `geo::CryostatID`,
118  // the following types are also aliases of the corresponding `geo::fhicl` ones
119  //
120 
121  /// Member type of validated `readout::CryostatID` parameter.
122  using CryostatID = IDparameter<readout::CryostatID>;
123 
124  /// Member type of optional validated `readout::CryostatID` parameter.
125  using OptionalCryostatID = OptionalID<readout::CryostatID>;
126 
127  /// Member type of sequence of `readout::CryostatID` parameters.
128  using CryostatIDsequence = IDsequence<readout::CryostatID>;
129 
130  /// Member type of optional sequence of `readout::CryostatID` parameters.
131  using OptionalCryostatIDsequence = OptionalIDsequence<readout::CryostatID>;
132 
133  // --- END -- Cryostat ID ----------------------------------------------------
134 
135 
136  // --- BEGIN -- TPC set ID ---------------------------------------------------
137 
138  /// Member type of validated `readout::TPCsetID` parameter.
139  using TPCsetID = IDparameter<readout::TPCsetID>;
140 
141  /// Member type of optional validated `readout::TPCsetID` parameter.
142  using OptionalTPCsetID = OptionalID<readout::TPCsetID>;
143 
144  /// Member type of sequence of `readout::TPCsetID` parameters.
145  using TPCsetIDsequence = IDsequence<readout::TPCsetID>;
146 
147  /// Member type of optional sequence of `readout::TPCsetID` parameters.
148  using OptionalTPCsetIDsequence = OptionalIDsequence<readout::TPCsetID>;
149 
150  // --- END -- TPC set ID -----------------------------------------------------
151 
152 
153  // --- BEGIN -- Readout plane ID ---------------------------------------------
154 
155  /// Member type of validated `readout::ROPID` parameter.
156  using ROPID = IDparameter<readout::ROPID>;
157 
158  /// Member type of optional validated `readout::ROPID` parameter.
159  using OptionalROPID = OptionalID<readout::ROPID>;
160 
161  /// Member type of sequence of `readout::ROPID` parameters.
162  using ROPIDsequence = IDsequence<readout::ROPID>;
163 
164  /// Member type of optional sequence of `readout::ROPID` parameters.
165  using OptionalROPIDsequence = OptionalIDsequence<readout::ROPID>;
166 
167  // --- END -- Readout plane ID -----------------------------------------------
168 
169 
170  /// @}
171  // --- END -- Validated configuration parameters for readout ID objects ------
172 
173 } // namespace readout::fhicl
174 
175 
176 // -----------------------------------------------------------------------------
177 
178 
179 #endif // LARCOREOBJ_SIMPLETYPESANDCONSTANTS_READOUT_TYPES_FHICL_H
180 
::fhicl::OptionalSequence< IDparameter< IDtype >> OptionalIDsequence
Member type of optional sequence of ID parameters.
::fhicl::OptionalTable< IDConfig< IDtype >> OptionalID
Member type of optional validated ID parameter.
OptionalID< readout::TPCsetID > OptionalTPCsetID
Member type of optional validated readout::TPCsetID parameter.
std::vector< ID > readIDsequence(IDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified ID sequence.
Classes identifying readout-related concepts.
unsigned int ID
IDparameter< readout::ROPID > ROPID
Member type of validated readout::ROPID parameter.
Traits for ID parameter objects.
ChannelGroupService::Name Name
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
Definition: 044_section.h:5
OptionalID< readout::ROPID > OptionalROPID
Member type of optional validated readout::ROPID parameter.
OptionalIDsequence< readout::TPCsetID > OptionalTPCsetIDsequence
Member type of optional sequence of readout::TPCsetID parameters.
IDparameter< readout::CryostatID > CryostatID
Member type of validated readout::CryostatID parameter.
ID readID(IDparameter< SrcID > const &atom)
Returns an ID extracted from the specified ID atom.
IDsequence< readout::ROPID > ROPIDsequence
Member type of sequence of readout::ROPID parameters.
OptionalIDsequence< readout::ROPID > OptionalROPIDsequence
Member type of optional sequence of readout::ROPID parameters.
OptionalIDsequence< readout::CryostatID > OptionalCryostatIDsequence
Member type of optional sequence of readout::CryostatID parameters.
std::optional< ID > readOptionalID(OptionalID< SrcID > const &atom)
Returns an ID extracted from the specified optional ID atom.
IDparameter< readout::TPCsetID > TPCsetID
Member type of validated readout::TPCsetID parameter.
std::optional< std::vector< ID > > readOptionalIDsequence(OptionalIDsequence< SrcID > const &seq)
Returns a vector of IDs extracted from the specified optional ID sequence.
Type of ID configuration structure (requires specialization)
Class identifying a set of planes sharing readout channels.
::fhicl::Sequence< IDparameter< IDtype >> IDsequence
Member type of sequence of ID parameters.
FHiCL objects representing geometry classes as configuration parameters.
OptionalID< readout::CryostatID > OptionalCryostatID
Member type of optional validated readout::CryostatID parameter.
#define Comment
::fhicl::Table< IDConfig< IDtype >> IDparameter
Member type of validated ID parameter.
IDsequence< readout::TPCsetID > TPCsetIDsequence
Member type of sequence of readout::TPCsetID parameters.
IDsequence< readout::CryostatID > CryostatIDsequence
Member type of sequence of readout::CryostatID parameters.
FHiCL objects representing geometry classes as configuration parameters.
Utilities for using geometry IDs in FHiCL validated configuration.
ID readParameter(IDparameter< SrcID > const &atom)
typename IDparameterTraits< IDparam >::ID_t IDof
Type of ID of the specified ID FHiCL parameter object/.