ReadoutDataContainers.h
Go to the documentation of this file.
1 /**
2  * @file larcorealg/Geometry/ReadoutDataContainers.h
3  * @brief Containers to hold one datum per TPC set or readout plane.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date September 7, 2019
6  * @ingroup Geometry
7  *
8  * This is a header-only library.
9  */
10 
11 #ifndef LARCOREALG_GEOMETRY_READOUTDATACONTAINERS_H
12 #define LARCOREALG_GEOMETRY_READOUTDATACONTAINERS_H
13 
14 // LArSoft libraries
18 
19 
20 namespace readout {
21 
22  template <typename T>
24 
25  template <typename T>
27 
28 } // namespace geo
29 
30 
31 // --- BEGIN Readout data containers -------------------------------------------
32 /// @name Readout data containers
33 /// @ingroup Geometry
34 /// @{
35 
36 //------------------------------------------------------------------------------
37 /**
38  * @brief Container with one element per readout TPC set.
39  * @tparam T type of the contained datum
40  * @see `geo::GeometryCore::makeTPCsetData`
41  *
42  * The container is of fixed size and can't be neither resized nor freed
43  * before destruction.
44  *
45  * Assumptions
46  * ============
47  *
48  * The following assumptions should be considered unchecked, and the behavior
49  * when they are violated undefined (but note that in debug mode some of them
50  * might be actually checked):
51  * * the container assumes the same number of TPC sets in each cryostat. While
52  * this is not effectively a necessary condition, keep in mind that this
53  * container has no notion whether a given TPC set actually exists in the
54  * geometry or not
55  * * at least one element is expected to be present
56  *
57  */
58 template <typename T>
60  : public geo::GeoIDdataContainer<T, readout::TPCsetIDmapper<>>
61 {
62 
64 
65  public:
66 
68 
69  /**
70  * @brief Default constructor: empty container.
71  * @see `resize()`
72  *
73  * The container starts with no room for any data.
74  * The only guarantee is that `empty()` is `true` and `size()` is `0`.
75  * Use `resize()` before anything else.
76  */
77  TPCsetDataContainer() = default;
78 
79  /**
80  * @brief Prepares the container with default-constructed data.
81  * @param nCryo number of cryostats
82  * @param nTPCsets number of TPC sets
83  *
84  * The container is sized to host data for `nCryo` cryostats, each with
85  * `nTPCsets` TPC sets. Each element in the container is default-constructed.
86  */
87  TPCsetDataContainer(unsigned int nCryo, unsigned int nTPCsets)
88  : BaseContainer_t({ nCryo, nTPCsets })
89  {}
90 
91  /**
92  * @brief Prepares the container with copies of the specified default value.
93  * @param nCryo number of cryostats
94  * @param nTPCsets number of TPC sets
95  * @param defValue the value to be replicated
96  *
97  * The container is sized to host data for `nCryo` cryostats, each with
98  * `nTPCsets` TPC sets. Each element in the container is a copy of defValue.
99  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
100  * auto const* geom = lar::providerFrom<geo::GeometryCore>();
101  * readout::TPCsetDataContainer<unsigned int> ROPsPerTPCset
102  * (geom->NCryostats(), geom->MaxTPCsets(), 3U);
103  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104  */
106  (unsigned int nCryo, unsigned int nTPCsets, value_type const& defValue)
107  : BaseContainer_t({ nCryo, nTPCsets }, defValue)
108  {}
109 
110 
111  // --- BEGIN Container modification ------------------------------------------
112  /// @name Container modification
113  /// @{
114 
115  /**
116  * @brief Prepares the container with default-constructed data.
117  * @param nCryo number of cryostats
118  * @param nTPCsets number of TPC sets
119  * @see `clear()`, `fill()`
120  *
121  * The container is sized to host data for `nCryo` cryostats, each with
122  * `nTPCsets` TPC sets. Each element in the container is default-constructed.
123  *
124  * Existing data is not touched, but it may be rearranged in a
125  * non-straightforward way.
126  */
127  void resize(unsigned int nCryo, unsigned int nTPCsets)
128  { BaseContainer_t::resize({ nCryo, nTPCsets }); }
129 
130  /**
131  * @brief Prepares the container initializing all its data.
132  * @param nCryo number of cryostats
133  * @param nTPCsets number of TPC sets
134  * @param defValue the value copied to fill all entries in the container
135  * @see `clear()`, `fill()`
136  *
137  * The container is sized to host data for `nCryo` cryostats, each with
138  * `nTPCsets` TPC sets. Each element in the container is a copy of `defValue`.
139  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
140  * auto const* geom = lar::providerFrom<geo::GeometryCore>();
141  * readout::TPCsetDataContainer<unsigned int> ROPsPerTPCset;
142  * ROPsPerTPCset.resize(geom->NCryostats(), geom->MaxTPCsets(), 3U);
143  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144  * Existing data is not touched, but it may be rearranged in a
145  * non-straightforward way.
146  */
147  void resize(unsigned int nCryo, unsigned int nTPCsets, T const& defValue)
148  { BaseContainer_t::resize({ nCryo, nTPCsets }, defValue); }
149 
150  /// @}
151  // --- END Container modification --------------------------------------------
152 
153 
154  // --- BEGIN Container status query ------------------------------------------
155  /// @name Container status query
156  /// @{
157 
158  /// Returns whether this container hosts data for the specified cryostat.
159  bool hasCryostat(readout::CryostatID const& cryoid) const
160  { return BaseContainer_t::hasElement(cryoid); }
161 
162  /// Returns whether this container hosts data for the specified TPC set.
163  bool hasTPCset(readout::TPCsetID const& tpcsetid) const
164  { return BaseContainer_t::hasElement(tpcsetid); }
165 
166  /// @}
167  // --- END Container status query --------------------------------------------
168 
169 
170 }; // class readout::TPCsetDataContainer<>
171 
172 
173 //------------------------------------------------------------------------------
174 /**
175  * @brief Container with one element per readout plane.
176  * @tparam T type of the contained datum
177  * @see `geo::GeometryCore::makeROPdata`
178  *
179  * The container is of fixed size and can't be neither resized nor freed
180  * before destruction.
181  *
182  * Assumptions
183  * ============
184  *
185  * The following assumptions should be considered unchecked, and the behavior
186  * when they are violated undefined (but note that in debug mode some of them
187  * might be actually checked):
188  * * the container assumes the same number of readout planes in all TPC set,
189  * and of TPC sets on all cryostats. While this is not effectively a necessary
190  * condition, keep in mind that this container has no notion whether a given
191  * readout plane or TPC set actually exists in the geometry or not
192  * * at least one element is expected to be present
193  *
194  */
195 template <typename T>
197  : public geo::GeoIDdataContainer<T, readout::ROPIDmapper<>>
198 {
199 
200  /// Base class.
202 
203  public:
204 
205  /**
206  * @brief Default constructor: empty container.
207  * @see `resize()`
208  *
209  * The container starts with no room for any data.
210  * The only guarantee is that `empty()` is `true` and `size()` is `0`.
211  * Use `resize()` before anything else.
212  */
213  ROPDataContainer() = default;
214 
215  /**
216  * @brief Prepares the container with default-constructed data.
217  * @param nCryo number of cryostats
218  * @param nTPCsets number of TPC sets per cryostat
219  * @param nROPs number of readout planes per TPC set
220  *
221  * The container is sized to host data for `nCryo` cryostats, each with
222  * `nTPCsets` TPC sets, each one with `nROPs` readout planes. Each element
223  * in the container is default-constructed.
224  */
226  (unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs)
227  : BaseContainer_t({ nCryo, nTPCsets, nROPs })
228  {}
229 
230  /**
231  * @brief Prepares the container with copies of the specified default value.
232  * @param nCryo number of cryostats
233  * @param nTPCsets number of TPC sets
234  * @param nROPs number of readout planes per TPC set
235  * @param defValue the value to be replicated
236  *
237  * The container is sized to host data for `nCryo` cryostats, each with
238  * `nTPCsets` TPC sets, and each of them with `nROPs` readout planes.
239  * Each element in the container is a copy of `defValue`.
240  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
241  * auto const* geom = lar::providerFrom<geo::GeometryCore>();
242  * readout::ROPDataContainer<unsigned int> countPerROP
243  * (geom->NCryostats(), geom->MaxTPCsets(), geom->MaxROPs(), 0U);
244  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245  */
247  unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs,
248  T const& defValue
249  )
250  : BaseContainer_t{ { nCryo, nTPCsets, nROPs }, defValue }
251  {}
252 
253 
254  // --- BEGIN Container modification ------------------------------------------
255  /// @name Container modification
256  /// @{
257 
258  /**
259  * @brief Prepares the container with default-constructed data.
260  * @param nCryo number of cryostats
261  * @param nTPCsets number of TPC sets
262  * @param nROPs number of readout planes per TPC set
263  * @see `clear()`, `fill()`
264  *
265  * The container is sized to host data for `nCryo` cryostats, each with
266  * `nTPCsets` TPC sets, and each of them with `nROPs` readout planes.
267  * Each element in the container is default-constructed.
268  *
269  * Existing data is not touched, but it may be rearranged in a
270  * non-straightforward way.
271  */
272  void resize(unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs)
273  { BaseContainer_t::resize({ nCryo, nTPCsets, nROPs }); }
274 
275  /**
276  * @brief Prepares the container initializing all its data.
277  * @param nCryo number of cryostats
278  * @param nTPCsets number of TPC sets
279  * @param nROPs number of readout planes per TPC set
280  * @param defValue the value copied to fill all entries in the container
281  * @see `clear()`, `fill()`
282  *
283  * The container is sized to host data for `nCryo` cryostats, each with
284  * `nTPCsets` TPC sets, and each of them with `nROPs` readout planes.
285  * Each element in the container is a copy of `defValue`.
286  *
287  * Existing data is not touched, but it may be rearranged in a
288  * non-straightforward way.
289  */
290  void resize(
291  unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs,
292  T const& defValue
293  )
294  { BaseContainer_t::resize({ nCryo, nTPCsets, nROPs }, defValue); }
295 
296  /// @}
297  // --- END Container modification --------------------------------------------
298 
299 
300  // --- BEGIN Container status query ------------------------------------------
301  /// @name Container status query
302  /// @{
303 
304  /// Returns whether this container hosts data for the specified cryostat.
305  bool hasCryostat(readout::CryostatID const& cryoid) const
306  { return BaseContainer_t::hasElement(cryoid); }
307 
308  /// Returns whether this container hosts data for the specified TPC set.
309  bool hasTPCset(readout::TPCsetID const& tpcsetid) const
310  { return BaseContainer_t::hasElement(tpcsetid); }
311 
312  /// Returns whether this container hosts data for the specified readout plane.
313  bool hasROP(readout::ROPID const& ropid) const
314  { return BaseContainer_t::hasElement(ropid); }
315 
316  /// @}
317  // --- END Container status query --------------------------------------------
318 
319 
320 }; // class readout::ROPDataContainer<>
321 
322 
323 /// @}
324 // --- END Readout data containers ---------------------------------------------
325 //------------------------------------------------------------------------------
326 
327 
328 #endif // LARCOREALG_GEOMETRY_READOUTDATACONTAINERS_H
Container with one element per readout TPC set.
Classes identifying readout-related concepts.
bool hasCryostat(readout::CryostatID const &cryoid) const
Returns whether this container hosts data for the specified cryostat.
Container with one element per readout plane.
ROPDataContainer(unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs, T const &defValue)
Prepares the container with copies of the specified default value.
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
void resize(unsigned int nCryo, unsigned int nTPCsets)
Prepares the container with default-constructed data.
Container with one element per geometry TPC.
void resize(unsigned int nCryo, unsigned int nTPCsets, T const &defValue)
Prepares the container initializing all its data.
void resize(unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs)
Prepares the container with default-constructed data.
Containers to hold one datum per TPC or plane.
geo::GeoIDdataContainer< T, readout::TPCsetIDmapper<>> BaseContainer_t
void resize(unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs, T const &defValue)
Prepares the container initializing all its data.
Class identifying a set of planes sharing readout channels.
bool hasTPCset(readout::TPCsetID const &tpcsetid) const
Returns whether this container hosts data for the specified TPC set.
bool hasROP(readout::ROPID const &ropid) const
Returns whether this container hosts data for the specified readout plane.
TPCsetDataContainer()=default
Default constructor: empty container.
bool hasCryostat(readout::CryostatID const &cryoid) const
Returns whether this container hosts data for the specified cryostat.
bool hasTPCset(readout::TPCsetID const &tpcsetid) const
Returns whether this container hosts data for the specified TPC set.
TPCsetDataContainer(unsigned int nCryo, unsigned int nTPCsets)
Prepares the container with default-constructed data.
Mapping between geometry/readout ID and flat index.
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
bool hasElement(GeoID const &id) const
Returns whether this container hosts data for the specified ID.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190