LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
IPhotonMappingTransformations.h
Go to the documentation of this file.
1 
10 #ifndef LARSIM_PHOTONPROPAGATION_LIBRARYMAPPINGTOOLS_IPHOTONMAPPINGTRANSFORMATIONS_H
11 #define LARSIM_PHOTONPROPAGATION_LIBRARYMAPPINGTOOLS_IPHOTONMAPPINGTRANSFORMATIONS_H
12 
13 // LArSoft libraries
14 #include "larcorealg/CoreUtils/ContainerMeta.h" // util::collection_value_t<>
15 #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t
17 
18 // C++ standard libraries
19 #include <functional> // std::cref()
20 #include <stdexcept> // std::out_of_range, std::domain_error
21 #include <utility> // std::forward()
22 #include <vector>
23 
24 namespace phot {
25 
116 
117  public:
118  virtual ~IPhotonMappingTransformations() = default;
119 
120  // --- BEGIN Data types ----------------------------------------------------
121  using OpDetID_t = int;
122 
124  using LibraryIndex_t = OpDetID_t; // currently bound to channel ID
125 
139  using LibraryIndexToOpDetMap = std::vector<OpDetID_t>;
140 
157  using OpDetToLibraryIndexMap = std::vector<LibraryIndex_t>; // FIXME former LibOpDetIDmap
158 
167  template <typename LibDataColl>
168  using MappedOpDetData_t =
171 
172  // --- END Data types ------------------------------------------------------
173 
179  static constexpr OpDetID_t InvalidOpDetID = std::numeric_limits<OpDetID_t>::max();
180 
187  std::numeric_limits<LibraryIndex_t>::max();
188 
189  // --- BEGIN Geometry mapping interface ------------------------------------
192 
215  virtual geo::Point_t detectorToLibrary(geo::Point_t const& location) const = 0;
216 
218  // --- END Geometry mapping interface --------------------------------------
219 
220  // --- BEGIN Optical detector mapping interface ----------------------------
232 
252  virtual LibraryIndex_t opDetToLibraryIndex(geo::Point_t const& location,
253  OpDetID_t opDetID) const = 0;
254 
271  virtual OpDetID_t libraryIndexToOpDet(geo::Point_t const& location,
272  LibraryIndex_t libIndex) const = 0;
273 
290  geo::Point_t const& location) const = 0;
291 
301  virtual std::size_t opDetMappingSize() const = 0;
302 
321  geo::Point_t const& location) const = 0;
322 
337  virtual std::size_t libraryMappingSize(geo::Point_t const& location) const = 0;
338 
340  // --- END Optical detector mapping interface ------------------------------
341 
342  // --- BEGIN Utility methods -----------------------------------------------
345 
370  template <typename Coll>
372  OpDetToLibraryIndexMap const& opDetToLibraryMap,
373  Coll&& source,
374  util::collection_value_t<Coll> defaultValue = {}) const;
375 
390  template <typename Coll>
391  auto applyOpDetMapping(geo::Point_t const& location,
392  Coll&& source,
393  util::collection_value_t<Coll> defaultValue = {}) const
394  {
395  return applyOpDetMapping(
396  opDetsToLibraryIndices(location), std::forward<Coll>(source), defaultValue);
397  }
398 
400  // --- END Utility methods -------------------------------------------------
401 
402  }; // class IPhotonMappingTransformations
403 
404 } // namespace phot
405 
406 //------------------------------------------------------------------------------
407 //--- Template implementation
408 //------------------------------------------------------------------------------
409 template <typename Coll>
411  OpDetToLibraryIndexMap const& opDetToLibraryMap,
412  Coll&& source,
413  util::collection_value_t<Coll> defaultValue /* = {} */
414 ) const -> MappedOpDetData_t<Coll>
415 {
416 
417  using std::size;
418 
419  // number of available destination slots (i.e. how many optical detectors)
420  auto const n = size(opDetToLibraryMap);
421 
422  return MappedOpDetData_t<Coll>{util::make_collection_reference(std::forward<Coll>(source)),
423  std::cref(opDetToLibraryMap) // mapping is referenced
424  ,
425  n // size
426  ,
427  defaultValue};
428 
429 } // phot::IPhotonMappingTransformations::applyOpDetMapping()
430 
431 //------------------------------------------------------------------------------
432 
433 #endif // LARSIM_PHOTONPROPAGATION_LIBRARYMAPPINGTOOLS_IPHOTONMAPPINGTRANSFORMATIONS_H
auto make_collection_reference(Coll &&coll)
Returns an object referencing to the data contained in coll.
virtual OpDetID_t libraryIndexToOpDet(geo::Point_t const &location, LibraryIndex_t libIndex) const =0
Returns the optical detector ID for the specified library index.
Data container for use with photon visibility libraries.
OpDetID_t LibraryIndex_t
Type describing a library index. FIXME former LibraryOpDetID_t.
virtual std::size_t opDetMappingSize() const =0
Expected number of mappings of optical detector into library index.
Collection of functions to transform photon mapping data.
virtual ~IPhotonMappingTransformations()=default
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
typename collection_reference_type< Coll >::type collection_reference_t
The type contained in util::collection_reference_type trait.
auto applyOpDetMapping(geo::Point_t const &location, Coll &&source, util::collection_value_t< Coll > defaultValue={}) const
Remaps a collection indexed by library index into one indexed by optical detector IDs according to th...
static constexpr LibraryIndex_t InvalidLibraryIndex
Value used for an invalid library index.
Definitions of geometry vector data types.
static constexpr OpDetID_t InvalidOpDetID
Value used to identify an invalid optical detector.
std::vector< OpDetID_t > LibraryIndexToOpDetMap
Type describing the mapping of optical detectors into library indices.
virtual geo::Point_t detectorToLibrary(geo::Point_t const &location) const =0
Returns the representation within the library of a detector location.
int OpDetID_t
Type describing a optical detector ID.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
MappedOpDetData_t< Coll > applyOpDetMapping(OpDetToLibraryIndexMap const &opDetToLibraryMap, Coll &&source, util::collection_value_t< Coll > defaultValue={}) const
Remaps a collection indexed by library index into one indexed by optical detector IDs...
General LArSoft Utilities.
virtual LibraryIndexToOpDetMap const & libraryIndicesToOpDets(geo::Point_t const &location) const =0
Returns a map of optical detectors identifiers, one for each library index.
A container for photon visibility mapping data.
virtual OpDetToLibraryIndexMap const & opDetsToLibraryIndices(geo::Point_t const &location) const =0
Returns a map of library indices as function of optical detectors.
virtual std::size_t libraryMappingSize(geo::Point_t const &location) const =0
Expected size of the mapping from library to optical detectors.
Char_t n[5]
typename collection_value_type< Coll >::type collection_value_t
Type contained in the collection Coll.
Definition: ContainerMeta.h:62
C++ metaprogramming utilities for dealing with containers.
virtual LibraryIndex_t opDetToLibraryIndex(geo::Point_t const &location, OpDetID_t opDetID) const =0
Returns the library index for the specified optical detector.
std::vector< LibraryIndex_t > OpDetToLibraryIndexMap
Type describing the mapping of library indices into optical detectors.