PhotonMappingIdentityTransformations.h
Go to the documentation of this file.
1 /**
2  * @file larsim/PhotonPropagation/LibraryMappingTools/PhotonMappingIdentityTransformations.h
3  * @brief A photon mapping identity transformation.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date March 20, 2019
6  * @see `larsim/PhotonPropagation/LibraryMappingTools/PhotonMappingIdentityTransformations_tool.cc`
7  *
8  */
9 
10 #ifndef LARSIM_PHOTONPROPAGATION_LIBRARYMAPPINGTOOLS_PHOTONMAPPINGIDENTITYTRANSFORMATIONS_H
11 #define LARSIM_PHOTONPROPAGATION_LIBRARYMAPPINGTOOLS_PHOTONMAPPINGIDENTITYTRANSFORMATIONS_H
12 
13 // LArSoft libraries
16 #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom()
17 
18 // framework libraries
20 
21 namespace geo { class GeometryCore; }
22 
23 namespace phot {
24 
25  /**
26  * @brief Trivial photon mapping transformation.
27  *
28  * This implementation of `phot::IPhotonMappingTransformations` interface
29  * uses the identity mapping to have the library space matching the world one.
30  *
31  * This is the most generic case when there are no symmetries to be exploited:
32  * neither locations nor the optical detectors are changed by the mapping.
33  *
34  * @note The documentation of this class describes the details of this
35  * implementation of `phot::IPhotonMappingTransformations` interface.
36  * For information about how to _use it_, see the documentation of that
37  * interface.
38  */
41  {
42 
43  public:
44  struct Config {
45 
46  // using Name = fhicl::Name;
47  // using Comment = fhicl::Comment;
48 
49  // no configuration required
50 
51  }; // struct Config
52 
54 
55 
56  /// Constructor: ignores the configuration.
58  : fGeom(lar::providerFrom<geo::Geometry>())
59  , fOpDetsToLibraryIndicesMap(makeOpDetsToLibraryIndicesMap())
60  , fLibraryIndicesToOpDetsMap(makeLibraryIndicesToOpDetsMap())
61  {}
62 
63  /// Constructor: ignores the configuration.
66  {}
67 
68 
69  // --- BEGIN Geometry mapping interface ------------------------------------
70  /// @name Geometry mapping interface
71  /// @{
72 
73  /**
74  * @brief Returns the representation within the library of a detector
75  * location.
76  * @param location position in world coordinates [cm]
77  * @return a vector expressing `location` in the library space
78  *
79  * The returned vector is an exact copy of `location`.
80  *
81  * No exception is ever thrown.
82  */
83  virtual geo::Point_t detectorToLibrary
84  (geo::Point_t const& location) const override
85  { return location; }
86 
87  /// @}
88  // --- END Geometry mapping interface --------------------------------------
89 
90 
91  // --- BEGIN Optical detector mapping interface ----------------------------
92  /// @name Optical detector mapping interface
93  /// @{
94 
95  /**
96  * @brief Maps an optical detector with its library index.
97  * @param location _(unused)_ world reference point
98  * @param opDetID ID of the optical detector to be mapped
99  * (as used, e.g., in `geo::GeometryCore::OpDetGeoFromOpDet()`)
100  * @return library index corresponding to the specified optical detector
101  * @see `libraryIndexToOpDet()`, `opDetsToLibraryIndices()`
102  *
103  * The mapping is trivial: each library index has the same value as the
104  * ID of the optical detector it corresponds to.
105  */
106  virtual LibraryIndex_t opDetToLibraryIndex
107  (geo::Point_t const& location, OpDetID_t opDetID) const override
108  { return LibraryIndex_t{ opDetID }; }
109 
110  /**
111  * @brief Maps a library index with an optical detector.
112  * @param location world reference point _(unused)_
113  * @param libIndex the library index to be mapped
114  * @return optical detector ID
115  * (as used, e.g., in `geo::GeometryCore::OpDetGeoFromOpDet()`)
116  * @see `opDetToLibraryIndex()`, `libraryIndicesToOpDets()`
117  *
118  * The mapping is trivial: each library index has the same value as the
119  * ID of the optical detector it corresponds to.
120  */
121  virtual OpDetID_t libraryIndexToOpDet
122  (geo::Point_t const& location, LibraryIndex_t libIndex) const override
123  { return OpDetID_t{ libIndex }; }
124 
125 
126  /**
127  * @brief Returns a map of library indices as function of optical detectors.
128  * @param location world reference point _(unused)_
129  * @return library indices for all optical detectors
130  * @see `opDetToLibraryIndex()`, `opDetsToLibraryIndices()`
131  *
132  * The mapping is trivial, as each library index has the same value as the
133  * ID of the optical detector it corresponds to.
134  * This mapping is global and does not depend on any location.
135  */
136  virtual OpDetToLibraryIndexMap const& opDetsToLibraryIndices
137  (geo::Point_t const& location) const override
138  { return fOpDetsToLibraryIndicesMap; }
139 
140  /**
141  * @brief Expected number of mappings of optical detector into library
142  * index.
143  * @return the expected size of the mapping of optical detectors
144  * @see `opDetsToLibraryIndices()`
145  *
146  * This is effectively the number of available optical detectors, as well
147  * as the size of the mapping as returned by `opDetsToLibraryIndices()`.
148  */
149  virtual std::size_t opDetMappingSize() const override
150  { return fOpDetsToLibraryIndicesMap.size(); }
151 
152 
153  /**
154  * @brief Returns a map of optical detectors identifiers, one for each
155  * library index.
156  * @param location a world reference point _(unused)_
157  * @return optical detector identifiers for all library indices
158  * @see `opDetsToLibraryIndices()`, `libraryIndexToOpDet()`
159  *
160  * The mapping is trivial, as each library index has the same value as the
161  * ID of the optical detector it corresponds to.
162  * This mapping is global and does not depend on any location.
163  */
164  virtual LibraryIndexToOpDetMap const& libraryIndicesToOpDets
165  (geo::Point_t const& location) const override
166  { return fLibraryIndicesToOpDetsMap; }
167 
168  /**
169  * @brief Size of the mapping of library optical detectors.
170  * @param location a world reference point _(unused)_
171  * @return the expected size of the mapping of library optical detectors
172  * @see `opDetsFromLibrary()`
173  *
174  * This is also the number of optical detectors.
175  */
176  virtual std::size_t libraryMappingSize
177  (geo::Point_t const& location) const override
178  { return fLibraryIndicesToOpDetsMap.size(); }
179 
180 
181  /// @}
182  // --- END Optical detector identifier mapping interface -------------------
183 
184 
185  protected:
186 
187  /// Detector geometry service provider.
188  geo::GeometryCore const* fGeom = nullptr;
189 
190  /// Complete optical detector identifier mapping world-to-library.
192 
193  /// Complete optical detector identifier mapping library-to-world.
195 
196 
197  /// Return a trivial global optical detector identifier mapping.
198  virtual LibraryIndexToOpDetMap makeLibraryIndicesToOpDetsMap() const;
199 
200  /// Return a trivial library index mapping.
201  virtual OpDetToLibraryIndexMap makeOpDetsToLibraryIndicesMap() const;
202 
203  }; // class PhotonMappingIdentityTransformations
204 
205 
206 } // namespace phot
207 
208 
209 #endif // LARSIM_PHOTONPROPAGATION_LIBRARYMAPPINGTOOLS_PHOTONMAPPINGIDENTITYTRANSFORMATIONS_H
Interface for transformation of photon visibility maps.
OpDetID_t LibraryIndex_t
Type describing a library index. FIXME former LibraryOpDetID_t.
LibraryIndexToOpDetMap fLibraryIndicesToOpDetsMap
Complete optical detector identifier mapping library-to-world.
Collection of functions to transform photon mapping data.
art framework interface to geometry description
static Config * config
Definition: config.cpp:1054
PhotonMappingIdentityTransformations(Config const &)
Constructor: ignores the configuration.
std::vector< OpDetID_t > LibraryIndexToOpDetMap
Type describing the mapping of optical detectors into library indices.
Description of geometry of one entire detector.
PhotonMappingIdentityTransformations(Parameters const &config)
Constructor: ignores the configuration.
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:184
int OpDetID_t
Type describing a optical detector ID.
General LArSoft Utilities.
LArSoft-specific namespace.
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
Definition: ServiceUtil.h:63
virtual std::size_t opDetMappingSize() const override
Expected number of mappings of optical detector into library index.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
OpDetToLibraryIndexMap fOpDetsToLibraryIndicesMap
Complete optical detector identifier mapping world-to-library.
std::vector< LibraryIndex_t > OpDetToLibraryIndexMap
Type describing the mapping of library indices into optical detectors.