LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
GeometryDataContainers.h
Go to the documentation of this file.
1 
9 #ifndef LARCOREALG_GEOMETRY_GEOMETRYDATACONTAINERS_H
10 #define LARCOREALG_GEOMETRY_GEOMETRYDATACONTAINERS_H
11 
12 // LArSoft libraries
16 
17 // Boost libraries
18 #include <boost/iterator/iterator_adaptor.hpp>
19 
20 // C/C++ standard libraries
21 #include <algorithm> // std::fill(), std::for_each()
22 #include <cassert>
23 #include <initializer_list>
24 #include <stdexcept> // std::out_of_range
25 #include <string>
26 #include <utility> // std::forward()
27 #include <vector>
28 
29 namespace geo {
30 
31  template <typename T, typename Mapper>
33 
34  template <typename T>
36 
37  template <typename T>
39 
40  // ---------------------------------------------------------------------------
41  namespace details {
42 
43  template <typename T>
45 
46  template <typename GeoIDdataContainerClass, typename BaseIterator>
48 
49  template <typename GeoIDIteratorClass>
51 
52  } // namespace details
53  // ---------------------------------------------------------------------------
54 
55 } // namespace geo
56 
57 // --- BEGIN Geometry data containers ----------------------------------------
58 
62 
97 template <typename T, typename Mapper>
99 
101 
104 
107 
110 
112  struct IDextractor {
113  template <typename Obj>
114  decltype(auto) operator()(Obj&& obj) const
115  {
116  return obj.ID();
117  }
118  }; // struct IDextractor
119 
120 public:
122  using Mapper_t = Mapper;
123 
124  using ID_t = typename Mapper_t::ID_t;
125 
128 
132  using pointer = typename Container_t::pointer;
138 
141 
144 
146 
153  GeoIDdataContainer() = default;
154 
166  GeoIDdataContainer(std::initializer_list<unsigned int> dims);
167 
180  GeoIDdataContainer(std::initializer_list<unsigned int> dims, value_type const& defValue);
181 
182  // --- BEGIN Container status query ----------------------------------------
185 
187  size_type size() const;
188 
190  size_type capacity() const;
191 
193  bool empty() const;
194 
196  template <std::size_t Level>
197  unsigned int dimSize() const;
198 
200  static constexpr unsigned int dimensions();
201 
203  template <typename GeoID>
204  bool hasElement(GeoID const& id) const;
205 
207  template <typename GeoID = ID_t>
208  GeoID firstID() const;
209 
211  template <typename GeoID = ID_t>
212  GeoID lastID() const;
213 
215  Mapper_t const& mapper() const;
216 
218  // --- END Container status query ------------------------------------------
219 
220  // --- BEGIN Element access ------------------------------------------------
223 
225 
226  reference operator[](ID_t const& id);
227 
229  const_reference operator[](ID_t const& id) const;
230 
233  reference at(ID_t const& id);
234 
237  const_reference at(ID_t const& id) const;
238 
240  reference first();
241 
243  const_reference first() const;
244 
246  reference last();
247 
249  const_reference last() const;
250 
252  // --- END Element access --------------------------------------------------
253 
254  // --- BEGIN Iterators -----------------------------------------------------
302 
305  iterator begin();
306 
308  iterator end();
309 
311  const_iterator begin() const;
312 
314  const_iterator end() const;
315 
317  const_iterator cbegin() const;
318 
320  const_iterator cend() const;
321 
323  item_iterator item_begin();
324 
326  item_iterator item_end();
327 
329  item_const_iterator item_begin() const;
330 
332  item_const_iterator item_end() const;
333 
335  item_const_iterator item_cbegin() const;
336 
338  item_const_iterator item_cend() const;
339 
341  auto items();
342 
344  auto items() const;
345 
347  // --- END Iterators -------------------------------------------------------
348 
349  // --- BEGIN Data modification ---------------------------------------------
357 
360  void fill(value_type value);
361 
363  void reset();
364 
376  template <typename Op>
377  Op apply(Op&& op);
378 
392  template <typename Op>
393  decltype(auto) apply(Op&& op) const;
394 
396  // --- END Data modification -------------------------------------------------
397 
398  // --- BEGIN Container modification ------------------------------------------
401 
415  void resize(std::initializer_list<unsigned int> dims);
416 
431  void resize(std::initializer_list<unsigned int> dims, value_type const& defValue);
432 
444  template <typename OT>
445  void resizeAs(GeoIDdataContainer<OT, Mapper_t> const& other);
446 
459  template <typename OT>
460  void resizeAs(GeoIDdataContainer<OT, Mapper_t> const& other, value_type const& defValue);
461 
468  void clear();
469 
471  // --- END Container modification --------------------------------------------
472 
473 private:
474  Mapper_t fMapper;
475 
476  Container_t fData;
477 
479  size_type index(ID_t const& id) const;
480 
482  ID_t ID(size_type const index) const;
483 
484 }; // class geo::GeoIDdataContainer<>
485 
486 //------------------------------------------------------------------------------
521 template <typename T>
522 class geo::TPCDataContainer : public geo::GeoIDdataContainer<T, geo::TPCIDmapper<>> {
523 
525 
526 public:
528 
537  TPCDataContainer() = default;
538 
547  TPCDataContainer(unsigned int nCryo, unsigned int nTPCs) : BaseContainer_t({nCryo, nTPCs}) {}
548 
565  TPCDataContainer(unsigned int nCryo, unsigned int nTPCs, value_type const& defValue)
566  : BaseContainer_t({nCryo, nTPCs}, defValue)
567  {}
568 
569  // --- BEGIN Container modification ------------------------------------------
572 
585  void resize(unsigned int nCryo, unsigned int nTPCs) { BaseContainer_t::resize({nCryo, nTPCs}); }
586 
605  void resize(unsigned int nCryo, unsigned int nTPCs, T const& defValue)
606  {
607  BaseContainer_t::resize({nCryo, nTPCs}, defValue);
608  }
609 
611  // --- END Container modification --------------------------------------------
612 
613  // --- BEGIN Container status query ------------------------------------------
616 
618  bool hasCryostat(CryostatID const& cryoid) const { return BaseContainer_t::hasElement(cryoid); }
619 
621  bool hasTPC(TPCID const& tpcid) const { return BaseContainer_t::hasElement(tpcid); }
622 
624  // --- END Container status query --------------------------------------------
625 
626 }; // class geo::details::TPCDataContainer<>
627 
628 //------------------------------------------------------------------------------
662 template <typename T>
663 class geo::PlaneDataContainer : public geo::GeoIDdataContainer<T, geo::PlaneIDmapper<>> {
664 
667 
668 public:
677  PlaneDataContainer() = default;
678 
689  PlaneDataContainer(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes)
690  : BaseContainer_t({nCryo, nTPCs, nPlanes})
691  {}
692 
709  PlaneDataContainer(unsigned int nCryo,
710  unsigned int nTPCs,
711  unsigned int nPlanes,
712  T const& defValue)
713  : BaseContainer_t{{nCryo, nTPCs, nPlanes}, defValue}
714  {}
715 
716  // --- BEGIN Container modification ------------------------------------------
719 
734  void resize(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes)
735  {
736  BaseContainer_t::resize({nCryo, nTPCs, nPlanes});
737  }
738 
760  void resize(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes, T const& defValue)
761  {
762  BaseContainer_t::resize({nCryo, nTPCs, nPlanes}, defValue);
763  }
764 
766  // --- END Container modification --------------------------------------------
767 
768  // --- BEGIN Container status query ------------------------------------------
771 
773  bool hasCryostat(CryostatID const& cryoid) const { return BaseContainer_t::hasElement(cryoid); }
774 
776  bool hasTPC(TPCID const& tpcid) const { return BaseContainer_t::hasElement(tpcid); }
777 
779  bool hasPlane(PlaneID const& planeid) const { return BaseContainer_t::hasElement(planeid); }
780 
782  // --- END Container status query --------------------------------------------
783 
784 }; // class geo::PlaneDataContainer
785 
786 //------------------------------------------------------------------------------
794 template <typename GeoIDmapperClass, typename BaseIterator>
796  : public boost::iterator_adaptor<
797  geo::details::GeoIDdataContainerIterator<GeoIDmapperClass, BaseIterator>,
798  BaseIterator> {
799 
801  using Mapper_t = GeoIDmapperClass;
802 
803  using BaseIterator_t = BaseIterator;
804 
806  using Index_t = typename Mapper_t::index_type;
807 
808  struct ExtraData_t {
809 
811  Mapper_t const* mapper = nullptr;
812 
814 
815  }; // struct ExtraData_t
816 
818 
820  BaseIterator_t const& current() const
821  {
822  return GeoIDdataContainerIterator::iterator_adaptor_::base();
823  }
824  BaseIterator_t& current() { return GeoIDdataContainerIterator::iterator_adaptor_::base(); }
825 
827  BaseIterator_t const& start() const { return fData.start; }
828 
830  Mapper_t const& mapper() const
831  {
832  assert(fData.mapper);
833  return *(fData.mapper);
834  }
835 
837  Index_t index() const { return static_cast<Index_t>(current() - start()); }
838 
839 public:
840  using ID_t = typename Mapper_t::ID_t;
841 
843  GeoIDdataContainerIterator() = default;
844 
847  BaseIterator_t const& start,
848  BaseIterator_t const& current)
849  : GeoIDdataContainerIterator::iterator_adaptor_(current), fData{&mapper, start}
850  {}
851 
853  template <typename OBaseIterator>
856  std::enable_if_t<std::is_convertible_v<OBaseIterator, BaseIterator_t>> = nullptr)
857  : GeoIDdataContainerIterator::iterator_adaptor_(other.base()), fData(other.fData)
858  {}
859 
861  ID_t ID() const { return mapper().ID(index()); }
862 
863 private:
864  // friend class boost::iterator_core_access;
865 
866  // there might be some need for other interoperability methods (comparison?)
867 
868 }; // geo::details::GeoIDdataContainerIterator
869 
878 template <typename GeoIDIteratorClass>
880  : public boost::iterator_adaptor<geo::details::GeoIDdataContainerItemIterator<GeoIDIteratorClass>,
881  GeoIDIteratorClass,
882  std::pair<typename GeoIDIteratorClass::ID_t,
883  typename GeoIDIteratorClass::reference> // Value
884  ,
885  boost::use_default // Category
886  ,
887  std::pair<typename GeoIDIteratorClass::ID_t,
888  typename GeoIDIteratorClass::reference> // Reference
889  > {
890  /*
891  * Implementation notes:
892  * * boost::transform_iterator can't be used to wrap
893  * `geo::GeoIDdataContainerIterator` because it acts on the value of
894  * the wrapped iterator, while we need to extract information from
895  * the iterator itself (its `ID()` data member)
896  * * we need to specify the type of reference the iterator returns,
897  * because... it's not a reference; this is not really a STL random
898  * access iterator since it dereferences to a temporary value (rvalue)
899  * like an input iterator can; but for the rest it's a full blown random
900  * access iterator (same stuff as the infamous `std::vector<bool>`)
901  *
902  */
903 
904  using GeoIDiterator_t = GeoIDIteratorClass;
905 
907 
908 public:
910  using ID_t = typename GeoIDiterator_t::ID_t;
911 
913  GeoIDdataContainerItemIterator() = default;
914 
917 
919  template <typename OGeoIDIteratorClass>
922  std::enable_if_t<std::is_convertible_v<OGeoIDIteratorClass, GeoIDiterator_t>> = nullptr)
923  : iterator_adaptor_(other.base())
924  {}
925 
926 private:
927  friend class boost::iterator_core_access;
928 
929  using iterator_adaptor_::base;
930 
931  typename iterator_adaptor_::reference dereference() const { return {base().ID(), *base()}; }
932 
933  // there might be some need for other interoperability methods (comparison?)
934 
935 }; // geo::details::GeoIDdataContainerItemIterator
936 
938 // --- END Geometry data containers --------------------------------------------
939 //------------------------------------------------------------------------------
940 
941 //------------------------------------------------------------------------------
942 //--- Template implementation
943 //------------------------------------------------------------------------------
944 //--- geo::details::GeoContainerData
945 //------------------------------------------------------------------------------
946 template <typename T>
948 
949  using Container_t = std::vector<T>;
950 
951 public:
952  // --- BEGIN STL container types ---------------------------------------------
955 
956  using value_type = typename Container_t::value_type;
957  using reference = typename Container_t::reference;
958  using const_reference = typename Container_t::const_reference;
959  using pointer = typename Container_t::pointer;
960  using const_pointer = typename Container_t::const_pointer;
961  using iterator = typename Container_t::iterator;
963  using reverse_iterator = typename Container_t::reverse_iterator;
964  using const_reverse_iterator = typename Container_t::const_reverse_iterator;
965  using difference_type = typename Container_t::difference_type;
966  using size_type = typename Container_t::size_type;
967 
969  // --- END STL container types -----------------------------------------------
970 
972 
973  // --- BEGIN Constructors ----------------------------------------------------
974 
976  GeoContainerData() = default;
977 
979  GeoContainerData(size_type size) : fData(size) {}
980 
981  // Prepares the container with copies of the specified default value.
982  GeoContainerData(size_type size, value_type const& defValue) : fData(size, defValue) {}
983 
984  // --- END Constructors ------------------------------------------------------
985 
986  // --- BEGIN Container status query ------------------------------------------
989 
991  size_type size() const { return fData.size(); }
992 
994  size_type capacity() const { return fData.capacity(); }
995 
997  bool empty() const { return fData.empty(); }
998 
1000  // --- END Container status query --------------------------------------------
1001 
1002  // --- BEGIN Data modification -----------------------------------------------
1010 
1013  void fill(value_type value) { std::fill(fData.begin(), fData.end(), value); }
1014 
1016  void reset() { fill(value_type{}); }
1017 
1029  template <typename Op>
1030  Op apply(Op&& op)
1031  {
1032  for (auto& data : fData)
1033  op(data);
1034  return op;
1035  }
1036 
1048  template <typename Op>
1049  Op apply(Op&& op) const
1050  {
1051  for (auto const& data : fData)
1052  op(data);
1053  return op;
1054  }
1055 
1057  // --- END Element access ----------------------------------------------------
1058 
1059  // --- BEGIN Container modification ------------------------------------------
1062 
1072  void resize(size_type size) { fData.resize(size); }
1073 
1084  void resize(size_type size, value_type const& defValue) { fData.resize(size, defValue); }
1085 
1092  void clear() { fData.clear(); }
1093 
1095  // --- END Container modification --------------------------------------------
1096 
1097  // --- BEGIN Element access --------------------------------------------------
1100 
1102  reference operator[](index_type index) { return fData[index]; }
1103 
1105  const_reference operator[](index_type index) const { return fData[index]; }
1106 
1108  // --- END Element access ----------------------------------------------------
1109 
1110  // --- BEGIN Iterators -------------------------------------------------------
1113 
1114  iterator begin() { return fData.begin(); }
1115  iterator end() { return fData.end(); }
1116  const_iterator begin() const { return fData.begin(); }
1117  const_iterator end() const { return fData.end(); }
1118  const_iterator cbegin() const { return fData.cbegin(); }
1119  const_iterator cend() const { return fData.cend(); }
1120 
1121  reverse_iterator rbegin() { return fData.rbegin(); }
1122  reverse_iterator rend() { return fData.rend(); }
1123  const_reverse_iterator rbegin() const { return fData.rbegin(); }
1124  const_reverse_iterator rend() const { return fData.rend(); }
1125  const_reverse_iterator crbegin() const { return fData.crbegin(); }
1126  const_reverse_iterator crend() const { return fData.crend(); }
1127 
1129  // --- END Iterators ---------------------------------------------------------
1130 
1132  template <typename Value, typename Upper>
1133  static bool bounded(Value v, Upper upper)
1134  {
1135  return (v >= 0) && (static_cast<size_type>(v) < upper);
1136  }
1137 
1138 private:
1140 
1141 }; // class geo::details::GeoContainerData
1142 
1143 //------------------------------------------------------------------------------
1144 //--- geo::GeoIDdataContainer
1145 //------------------------------------------------------------------------------
1146 template <typename T, typename Mapper>
1147 geo::GeoIDdataContainer<T, Mapper>::GeoIDdataContainer(std::initializer_list<unsigned int> dims)
1148  : fMapper(dims), fData(fMapper.size())
1149 {
1150  assert(!fData.empty());
1151 }
1152 
1153 //------------------------------------------------------------------------------
1154 template <typename T, typename Mapper>
1155 geo::GeoIDdataContainer<T, Mapper>::GeoIDdataContainer(std::initializer_list<unsigned int> dims,
1156  value_type const& defValue)
1157  : fMapper(dims), fData(fMapper.computeSize(), defValue)
1158 {
1159  assert(!fData.empty());
1160 }
1161 
1162 //------------------------------------------------------------------------------
1163 template <typename T, typename Mapper>
1165 {
1166  return fData.size();
1167 }
1168 
1169 //------------------------------------------------------------------------------
1170 template <typename T, typename Mapper>
1172 {
1173  return fData.capacity();
1174 }
1175 
1176 //------------------------------------------------------------------------------
1177 template <typename T, typename Mapper>
1179 {
1180  return fData.empty();
1181 }
1182 
1183 //------------------------------------------------------------------------------
1184 template <typename T, typename Mapper>
1185 template <std::size_t Level>
1187 {
1188  return mapper().template dimSize<Level>();
1189 }
1190 
1191 //------------------------------------------------------------------------------
1192 template <typename T, typename Mapper>
1194 {
1195  return Mapper_t::dimensions();
1196 }
1197 
1198 //------------------------------------------------------------------------------
1199 template <typename T, typename Mapper>
1200 template <typename GeoID>
1202 {
1203  return mapper().template hasElement<GeoID>(id);
1204 }
1205 
1206 //------------------------------------------------------------------------------
1207 template <typename T, typename Mapper>
1208 template <typename GeoID /* = ID_t */>
1210 {
1211  return mapper().template firstID<GeoID>();
1212 }
1213 
1214 //------------------------------------------------------------------------------
1215 template <typename T, typename Mapper>
1216 template <typename GeoID /* = ID_t */>
1218 {
1219  return mapper().template lastID<GeoID>();
1220 }
1221 
1222 //------------------------------------------------------------------------------
1223 template <typename T, typename Mapper>
1225 {
1226  return fMapper;
1227 }
1228 
1229 //------------------------------------------------------------------------------
1230 template <typename T, typename Mapper>
1232 {
1233  return fData[mapper().index(id)];
1234 }
1235 
1236 //------------------------------------------------------------------------------
1237 template <typename T, typename Mapper>
1239 {
1240  return fData[mapper().index(id)];
1241 }
1242 
1243 //------------------------------------------------------------------------------
1244 template <typename T, typename Mapper>
1246 {
1247  if (hasElement(id)) return operator[](id);
1248  throw std::out_of_range("No data for " + std::string(id));
1249 }
1250 
1251 //------------------------------------------------------------------------------
1252 template <typename T, typename Mapper>
1254 {
1255  if (hasElement(id)) return operator[](id);
1256  throw std::out_of_range("No data for " + std::string(id));
1257 }
1258 
1259 //------------------------------------------------------------------------------
1260 template <typename T, typename Mapper>
1262 {
1263  return operator[](firstID());
1264 }
1265 
1266 //------------------------------------------------------------------------------
1267 template <typename T, typename Mapper>
1269 {
1270  return operator[](firstID());
1271 }
1272 
1273 //------------------------------------------------------------------------------
1274 template <typename T, typename Mapper>
1276 {
1277  return operator[](lastID());
1278 }
1279 
1280 //------------------------------------------------------------------------------
1281 template <typename T, typename Mapper>
1283 {
1284  return operator[](lastID());
1285 }
1286 
1287 //------------------------------------------------------------------------------
1288 template <typename T, typename Mapper>
1290 {
1291  return {mapper(), fData.begin(), fData.begin()};
1292 }
1293 
1294 //------------------------------------------------------------------------------
1295 template <typename T, typename Mapper>
1297 {
1298  return {mapper(), fData.begin(), fData.end()};
1299 }
1300 
1301 //------------------------------------------------------------------------------
1302 template <typename T, typename Mapper>
1304 {
1305  return {mapper(), fData.begin(), fData.begin()};
1306 }
1307 
1308 //------------------------------------------------------------------------------
1309 template <typename T, typename Mapper>
1311 {
1312  return {mapper(), fData.begin(), fData.end()};
1313 }
1314 
1315 //------------------------------------------------------------------------------
1316 template <typename T, typename Mapper>
1318 {
1319  return begin();
1320 }
1321 
1322 //------------------------------------------------------------------------------
1323 template <typename T, typename Mapper>
1325 {
1326  return end();
1327 }
1328 
1329 //------------------------------------------------------------------------------
1330 template <typename T, typename Mapper>
1332 {
1333  return {begin()};
1334 }
1335 
1336 //------------------------------------------------------------------------------
1337 template <typename T, typename Mapper>
1339 {
1340  return {end()};
1341 }
1342 
1343 //------------------------------------------------------------------------------
1344 template <typename T, typename Mapper>
1346 {
1347  return {begin()};
1348 }
1349 
1350 //------------------------------------------------------------------------------
1351 template <typename T, typename Mapper>
1353 {
1354  return {end()};
1355 }
1356 
1357 //------------------------------------------------------------------------------
1358 template <typename T, typename Mapper>
1360 {
1361  return item_begin();
1362 }
1363 
1364 //------------------------------------------------------------------------------
1365 template <typename T, typename Mapper>
1367 {
1368  return item_end();
1369 }
1370 
1371 //------------------------------------------------------------------------------
1372 template <typename T, typename Mapper>
1374 {
1375  return util::span{item_begin(), item_end()};
1376 }
1377 
1378 //------------------------------------------------------------------------------
1379 template <typename T, typename Mapper>
1381 {
1382  return util::span{item_begin(), item_end()};
1383 }
1384 
1385 //------------------------------------------------------------------------------
1386 template <typename T, typename Mapper>
1388 {
1389  fData.fill(value);
1390 }
1391 
1392 //------------------------------------------------------------------------------
1393 template <typename T, typename Mapper>
1395 {
1396  fData.reset();
1397 }
1398 
1399 //------------------------------------------------------------------------------
1400 template <typename T, typename Mapper>
1401 template <typename Op>
1403 {
1404  return fData.apply(std::forward<Op>(op));
1405 }
1406 
1407 //------------------------------------------------------------------------------
1408 template <typename T, typename Mapper>
1409 void geo::GeoIDdataContainer<T, Mapper>::resize(std::initializer_list<unsigned int> dims)
1410 {
1411  fMapper.resize(dims);
1412  fData.resize(mapper().size());
1413 }
1414 
1415 //------------------------------------------------------------------------------
1416 template <typename T, typename Mapper>
1417 void geo::GeoIDdataContainer<T, Mapper>::resize(std::initializer_list<unsigned int> dims,
1418  value_type const& defValue)
1419 {
1420  fMapper.resize(dims);
1421  fData.resize(mapper().size(), defValue);
1422 }
1423 
1424 //------------------------------------------------------------------------------
1425 template <typename T, typename Mapper>
1426 template <typename OT>
1428 {
1429  fMapper.resizeAs(other.mapper());
1430  fData.resize(mapper().size());
1431 }
1432 
1433 //------------------------------------------------------------------------------
1434 template <typename T, typename Mapper>
1435 template <typename OT>
1437  value_type const& defValue)
1438 {
1439  fMapper.resizeAs(other.mapper());
1440  fData.resize(mapper().size(), defValue);
1441 }
1442 
1443 //------------------------------------------------------------------------------
1444 template <typename T, typename Mapper>
1446 {
1447  fMapper.clear();
1448  fData.clear();
1449 }
1450 
1451 //------------------------------------------------------------------------------
1452 template <typename T, typename Mapper>
1453 template <typename Op>
1454 decltype(auto) geo::GeoIDdataContainer<T, Mapper>::apply(Op&& op) const
1455 {
1456  return fData.apply(std::forward<Op>(op));
1457 }
1458 
1459 //------------------------------------------------------------------------------
1460 template <typename T, typename Mapper>
1462 {
1463  return mapper().index(id);
1464 }
1465 
1466 //------------------------------------------------------------------------------
1467 template <typename T, typename Mapper>
1469 {
1470  return mapper().ID(index);
1471 }
1472 
1473 //------------------------------------------------------------------------------
1474 
1475 #endif // LARCOREALG_GEOMETRY_GEOMETRYDATACONTAINERS_H
void reset()
Sets all the elements to a default-constructed value_type.
typename Container_t::iterator iterator
intermediate_table::iterator iterator
Functor to extract an ID data member.
static bool bounded(Value v, Upper upper)
Returns whether the specified value is between 0 and the upper limit.
auto items()
Returns an object suitable for a range-for loop with item_iterator.
void resize(unsigned int nCryo, unsigned int nTPCs, T const &defValue)
Prepares the container initializing all its data.
Mapper_t const & mapper() const
Returns the mapper object used to convert ID&#39;s and container positions.
bool hasPlane(PlaneID const &planeid) const
Returns whether this container hosts data for the specified plane.
Item iterator for geo::GeoIDdataContainer class.
BaseIterator_t const & start() const
Returns the iterator to the begin element.
GeoID firstID() const
Returns the ID of the first element with GeoID type.
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
reference at(ID_t const &id)
An object with a begin and end iterator.
const_reverse_iterator crend() const
const_reverse_iterator crbegin() const
bool hasCryostat(CryostatID const &cryoid) const
Returns whether this container hosts data for the specified cryostat.
GeoID lastID() const
Returns the ID of the last covered element with GeoID type.
typename Container_t::const_pointer const_pointer
iterator end()
Returns an iterator to past the end of the data.
Iterator for geo::GeoIDdataContainer class.
iterator_adaptor_::reference dereference() const
size_type capacity() const
Returns the number of elements the container has memory for.
GeoIDdataContainerItemIterator(GeoIDiterator_t const &iter)
Constructor: points to data pointed by current.
size_type capacity() const
Returns the number of elements the container has memory for.
The data type to uniquely identify a Plane.
Definition: geo_types.h:364
Mapping between geometry/readout ID and flat index.This is a header-only library. ...
const_iterator cbegin() const
Returns a constant iterator to the beginning of the data.
TPCDataContainer(unsigned int nCryo, unsigned int nTPCs)
Prepares the container with default-constructed data.
reference last()
Returns the element for the last ID (unchecked).
typename Container_t::reverse_iterator reverse_iterator
STL namespace.
ExtraData_t fData
Data for extended features of this iterator.
intermediate_table::const_iterator const_iterator
ID_t ID() const
Returns the ID corresponding to the current element.
size_type index_type
Type used internally (so far) for indexing.
Container with one element per geometry wire plane.
typename Container_t::const_reverse_iterator const_reverse_iterator
bool empty() const
Returns whether the container has no elements (false by assumptions).
void resize(size_type size, value_type const &defValue)
Prepares the container with copies of the specified default value.
Simple class with a begin and an end.
Definition: span.h:129
GeoIDdataContainerIterator(GeoIDdataContainerIterator< Mapper_t, OBaseIterator > const &other, std::enable_if_t< std::is_convertible_v< OBaseIterator, BaseIterator_t >>=nullptr)
Generalized copy constructor, only if argument iterator can be converted.
void resize(unsigned int nCryo, unsigned int nTPCs)
Prepares the container with default-constructed data.
GeoIDdataContainerItemIterator(GeoIDdataContainerItemIterator< OGeoIDIteratorClass > const &other, std::enable_if_t< std::is_convertible_v< OGeoIDIteratorClass, GeoIDiterator_t >>=nullptr)
Generalized copy constructor, only if argument iterator can be converted.
BaseIterator BaseIterator_t
Type of iterator to the actual data.
Op apply(Op &&op) const
Applies an operation on all elements.
Container with one element per geometry TPC.
item_const_iterator item_cbegin() const
Returns a item constant iterator to the beginning of the data.
void resize(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes, T const &defValue)
Prepares the container initializing all its data.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void reset()
Sets all the elements to a default-constructed value_type.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
GeoContainerData(size_type size)
Prepares the container with default-constructed data.
ID_t ID(size_type const index) const
Returns the ID corresponding to a internal index in the storage area.
Container with one element per geometry TPC.
typename Mapper_t::ID_t ID_t
Type used as ID for this container.
size_type size() const
Returns the number of elements in the container.
bool hasTPC(TPCID const &tpcid) const
Returns whether this container hosts data for the specified TPC.
typename Container_t::difference_type difference_type
reference operator[](index_type index)
Returns the element for the specified index.
typename Container_t::size_type size_type
typename Mapper_t::index_type Index_t
Type of index in the container mapping.
typename BaseContainer_t::value_type value_type
void resizeAs(GeoIDdataContainer< OT, Mapper_t > const &other)
Prepares the container with default-constructed data.
typename Container_t::const_reference const_reference
GeoIDdataContainerIterator(Mapper_t const &mapper, BaseIterator_t const &start, BaseIterator_t const &current)
Constructor: points to data pointed by current.
item_iterator item_begin()
Returns an item iterator to the beginning of the data.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
typename Container_t::reference reference
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
Definition of data types for geometry description.
const_reference operator[](index_type index) const
Returns the element for the specified index (read-only).
Mapping for TPC identifiers.
reference first()
Returns the element for the first ID (unchecked).
typename GeoIDiterator_t::ID_t ID_t
Type of the ID in this iterator.
double value
Definition: spectrum.C:18
const_reverse_iterator rend() const
reference operator[](ID_t const &id)
Returns the element for the specified geometry element.
Mapper Mapper_t
Type of mapper between IDs and index.
TPCDataContainer(unsigned int nCryo, unsigned int nTPCs, value_type const &defValue)
Prepares the container with copies of the specified default value.
GeoIDIteratorClass GeoIDiterator_t
Type of wrapped iterator.
item_iterator item_end()
Returns an item iterator to past the end of the data.
void clear()
Makes the container empty, with no usable storage space.
Op apply(Op &&op)
Applies an operation on all elements.
static constexpr unsigned int dimensions()
Dimensions of the ID of this container.
void fill(value_type value)
Sets all elements to the specified value (copied).
bool hasTPC(TPCID const &tpcid) const
Returns whether this container hosts data for the specified TPC.
void resize(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes)
Prepares the container with default-constructed data.
GeoContainerData(size_type size, value_type const &defValue)
typename Container_t::value_type value_type
typename Container_t::iterator BaseIter_t
Type of iterator to the data.
BaseIterator_t const & current() const
Returns the iterator to the current element.
typename Container_t::const_iterator BaseConstIter_t
Type of constant iterator to the data.
typename Container_t::const_iterator const_iterator
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:85
typename BaseMapper_t::ID_t ID_t
PlaneDataContainer(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes, T const &defValue)
Prepares the container with copies of the specified default value.
Mapper_t const & mapper() const
Returns the mapping of the container being iterated.
size_type index(ID_t const &id) const
Returns the internal index of the specified ID in the storage area.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
Index_t index() const
Returns the index of the current element.
void resize(size_type size)
Prepares the container with default-constructed data.
size_type size() const
Returns the number of elements in the container.
typename Container_t::pointer pointer
bool empty() const
Returns whether the container has no elements (false by assumptions).
PlaneDataContainer(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes)
Prepares the container with default-constructed data.
BaseIterator_t start
Iterator to the first element.
ROOT libraries.
unsigned int dimSize() const
Dimensions of the Level dimension of this container.
typename Mapper_t::ID_t ID_t
Type of the ID in this iterator.
typename GeoIDdataContainerItemIterator::iterator_adaptor_ iterator_adaptor_
void clear()
Makes the container empty, with no usable storage space.
GeoIDdataContainer()=default
Default constructor: container has no room at all.
Mapper_t fMapper
Mapping of IDs to indices.
Container_t fData
Data storage area.
Container_t fData
Data storage.
const_iterator cend() const
Returns a constant iterator to past the end of the data.
Op apply(Op &&op)
Applies an operation on all elements.
GeoIDmapperClass Mapper_t
< Type of mapping of the container this class iterates.
item_const_iterator item_cend() const
Returns a item constant iterator to past the end of the data.
vec_iX clear()
iterator begin()
Returns an iterator to the beginning of the data.
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
void fill(value_type value)
Sets all elements to the specified value (copied).
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:187
bool hasCryostat(CryostatID const &cryoid) const
Returns whether this container hosts data for the specified cryostat.
const_reverse_iterator rbegin() const
Mapper_t const * mapper
Mapping of the container being iterated.