All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
phot::ICARUSPhotonMappingTransformations Class Reference

Photon library mapping for ICARUS geometry. More...

#include <ICARUSPhotonMappingTransformations.h>

Inheritance diagram for phot::ICARUSPhotonMappingTransformations:
phot::IPhotonMappingTransformations

Classes

struct  Config
 

Public Types

using Parameters = art::ToolConfigTable< Config >
 
- Public Types inherited from phot::IPhotonMappingTransformations
using OpDetID_t = int
 Type describing a optical detector ID. More...
 
using LibraryIndex_t = OpDetID_t
 Type describing a library index. FIXME former LibraryOpDetID_t. More...
 
using LibraryIndexToOpDetMap = std::vector< OpDetID_t >
 Type describing the mapping of optical detectors into library indices. More...
 
using OpDetToLibraryIndexMap = std::vector< LibraryIndex_t >
 Type describing the mapping of library indices into optical detectors. More...
 
template<typename LibDataColl >
using MappedOpDetData_t = phot::OpDetVisibilityData< util::collection_reference_t< LibDataColl >, util::collection_reference_t< OpDetToLibraryIndexMap const > >
 Type of optical detector data collection. More...
 

Public Member Functions

 ICARUSPhotonMappingTransformations (Config const &config)
 Constructor. More...
 
 ICARUSPhotonMappingTransformations (Parameters const &config)
 Constructor: ignores the configuration. More...
 
template<typename OutputIndex , typename InputIndex , template< typename...> typename Container>
auto invertMapping (Container< OutputIndex > const &directMap, std::size_t size, InputIndex invalidIndex) -> Container< InputIndex >
 Inverts a given mapping. More...
 
Geometry mapping interface
virtual geo::Point_t detectorToLibrary (geo::Point_t const &location) const override
 Returns the representation within the library of a detector location. More...
 
Optical detector mapping interface
virtual LibraryIndex_t opDetToLibraryIndex (geo::Point_t const &location, OpDetID_t opDetID) const override
 Returns the library index for the specified optical detector. More...
 
virtual OpDetID_t libraryIndexToOpDet (geo::Point_t const &location, LibraryIndex_t libIndex) const override
 Returns the optical detector ID for the specified library index. More...
 
virtual OpDetToLibraryIndexMap
const & 
opDetsToLibraryIndices (geo::Point_t const &location) const override
 Returns a map of library indices as function of optical detectors. More...
 
virtual std::size_t opDetMappingSize () const override
 Expected number of mappings of optical detector into library index. More...
 
virtual LibraryIndexToOpDetMap
const & 
libraryIndicesToOpDets (geo::Point_t const &location) const override
 Returns a map of identifiers of optical detectors for each library index, for the library appropriate around location More...
 
virtual std::size_t libraryMappingSize (geo::Point_t const &location) const override
 Expected size of the mapping from library to optical detectors. More...
 
- Public Member Functions inherited from phot::IPhotonMappingTransformations
virtual ~IPhotonMappingTransformations ()=default
 
template<typename Coll >
auto applyOpDetMapping (OpDetToLibraryIndexMap const &opDetToLibraryMap, Coll &&source, util::collection_value_t< Coll > defaultValue) const -> MappedOpDetData_t< Coll >
 
template<typename Coll >
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. More...
 
template<typename Coll >
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 the mapping at location. More...
 

Protected Member Functions

geo::CryostatID whichCryostat (geo::Point_t const &point) const
 Returns which cryostat better contain point. Never invalid so far. More...
 
OpDetToLibraryIndexMap const & opDetsToLibraryIndicesImpl (geo::Point_t const &location) const
 
LibraryIndexToOpDetMap const & libraryIndicesToOpDetsImpl (geo::Point_t const &location) const
 
void prepareGeometryMapping ()
 
void prepareLibraryMappings (LibraryIndexToOpDetMap const &libraryIndices)
 
void prepareMappings (LibraryIndexToOpDetMap const &libraryIndices)
 Extracts the necessary information for mapping from the geometry. More...
 
void dumpMapping () const
 Writes the current mapping information into the console. Debug stuff. More...
 

Static Protected Member Functions

template<typename OutputIndex , typename InputIndex , template< typename...> typename Container>
static Container< InputIndex > invertMapping (Container< OutputIndex > const &directMap, std::size_t size, InputIndex invalidIndex)
 Inverts a given mapping. More...
 

Protected Attributes

bool fDumpMapping = false
 Whether to dump mapping on initialization. More...
 
geo::GeometryCore const * fGeom = nullptr
 Detector geometry service provider. Not really used. More...
 
std::vector< geo::Vector_tfTranslations
 Translation of the point. More...
 
geo::Length_t fSwitchPoint
 Switch coordinate on x axis [cm]. More...
 
unsigned int fNOpDetChannels
 
std::vector< int > fChannelShifts
 Amount of channel number shifting indexed by cryostat. Not really used. More...
 
std::vector
< LibraryIndexToOpDetMap
fLibraryIndexToOpDetMaps
 Library to detector channel mappings, indexed by cryostat number. More...
 
LibraryIndexToOpDetMap fInvalidLibraryIndexToOpDetMap
 A library-to-detector mapping for invalid points. More...
 
std::vector
< OpDetToLibraryIndexMap
fOpDetToLibraryIndexMaps
 Detector channel to library mappings, indexed by cryostat number. More...
 
OpDetToLibraryIndexMap fInvalidOpDetToLibraryIndexMap
 A detector-to-library mapping for invalid points. More...
 

Additional Inherited Members

- Static Public Attributes inherited from phot::IPhotonMappingTransformations
static constexpr OpDetID_t InvalidOpDetID = std::numeric_limits<OpDetID_t>::max()
 Value used to identify an invalid optical detector. More...
 
static constexpr LibraryIndex_t InvalidLibraryIndex = std::numeric_limits<LibraryIndex_t>::max()
 Value used for an invalid library index. More...
 

Detailed Description

Photon library mapping for ICARUS geometry.

This is an implementation of phot::IPhotonMappingTransformation interface to exploit ICARUS detector symmetries.

The current implementation only exploits the fact that the two cryostats are identical, and ignores the symmetry respect to the cathode within each of the cryostats.

The required library is expected to cover the first 180 PMT channels (the ones pertaining the first cryostat, C:0), and the full volume of the TPC.

When requested a point in the first cryostat (C:0), the point is used directly in the visibility library to get visibility on PMT channels 0 to 179 (the lower half). The mapping then maps the remaining PMT channels (180 to 359) to be invalid and with default value of 0.

When requested a point in the other cryostat (C:1), the point is translated into the first one to get visibility of PMT channels 0 to 179 (the lower half). The mapping then translates those channels into the range 180 to 359, and maps the remaining PMT channels (0 to 179) to be invalid and with default value of 0.

Note that the content of the library for channels 180 to 359 is always ignored, and it may well be absent.

Definition at line 58 of file ICARUSPhotonMappingTransformations.h.

Member Typedef Documentation

Definition at line 82 of file ICARUSPhotonMappingTransformations.h.

Constructor & Destructor Documentation

phot::ICARUSPhotonMappingTransformations::ICARUSPhotonMappingTransformations ( Config const &  config)

Constructor.

Definition at line 31 of file ICARUSPhotonMappingTransformations.cxx.

32  : fDumpMapping(config.DumpMapping())
33  , fGeom(lar::providerFrom<geo::Geometry>())
35 {
36  LibraryIndexToOpDetMap libraryIndices;
37  if (!config.CryostatChannelRemap(libraryIndices)) {
38  assert(fNOpDetChannels > 0U); // if no mapping is specified, we need to know
39  unsigned int nCryoChannels = fGeom->Cryostat(0U).NOpDet();
40  libraryIndices.resize(nCryoChannels);
41  std::iota(libraryIndices.begin(), libraryIndices.end(), 0U);
42  }
43  prepareMappings(libraryIndices);
44 
45 } // phot::ICARUSPhotonMappingTransformations::ICARUSPhotonMappingTransformations()
bool fDumpMapping
Whether to dump mapping on initialization.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
std::vector< OpDetID_t > LibraryIndexToOpDetMap
Type describing the mapping of optical detectors into library indices.
geo::GeometryCore const * fGeom
Detector geometry service provider. Not really used.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
Definition: CryostatGeo.h:361
void prepareMappings(LibraryIndexToOpDetMap const &libraryIndices)
Extracts the necessary information for mapping from the geometry.
phot::ICARUSPhotonMappingTransformations::ICARUSPhotonMappingTransformations ( Parameters const &  config)
inline

Constructor: ignores the configuration.

Definition at line 89 of file ICARUSPhotonMappingTransformations.h.

91  {}
ICARUSPhotonMappingTransformations(Config const &config)
Constructor.

Member Function Documentation

geo::Point_t phot::ICARUSPhotonMappingTransformations::detectorToLibrary ( geo::Point_t const &  location) const
overridevirtual

Returns the representation within the library of a detector location.

Parameters
locationposition in world coordinates [cm]
Returns
a vector expressing location in the library space

The returned vector is shifted as it were on the first cryostat.

No exception is ever thrown.

Implements phot::IPhotonMappingTransformations.

Definition at line 50 of file ICARUSPhotonMappingTransformations.cxx.

51 {
52  geo::CryostatID onCryo = whichCryostat(location);
53  return onCryo? location + fTranslations[onCryo.Cryostat]: location;
54 } // phot::ICARUSPhotonMappingTransformations::detectorToLibrary()
std::vector< geo::Vector_t > fTranslations
Translation of the point.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
geo::CryostatID whichCryostat(geo::Point_t const &point) const
Returns which cryostat better contain point. Never invalid so far.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void phot::ICARUSPhotonMappingTransformations::dumpMapping ( ) const
protected

Writes the current mapping information into the console. Debug stuff.

Definition at line 315 of file ICARUSPhotonMappingTransformations.cxx.

315  {
316  mf::LogInfo log("ICARUSPhotonMappingTransformations");
317 
318  log << "ICARUSPhotonMappingTransformations mapping";
319 
320  log << "\nMapping of geometry: '" << fGeom->DetectorName() << "':"
321  << "\n - " << fGeom->Ncryostats() << " cryostats"
322  << "\n - optical channels: " << fNOpDetChannels
323  << "\n - maximum optical detector channel number: " << fGeom->MaxOpChannel()
324  << "\n"
325  ;
326 
327  log << "\nThe switch point is at x=" << fSwitchPoint << " cm.";
328 
329  constexpr unsigned int PageBreak = 12;
330 
331  for (auto const& cryo: fGeom->IterateCryostats()) {
332 
333  auto const c = cryo.ID().Cryostat;
334 
335  log << "\n" << cryo.ID() << ":"
336  << "\n * optical detectors: " << cryo.NOpDet()
337  << "\n * channel -> library shift: " << fChannelShifts[c]
338  << "\n * translation: " << fTranslations[c];
339 
340  unsigned int pager;
341 
342  // print library to detector mapping
343  auto const& libOpDetIDmap = fLibraryIndexToOpDetMaps[c];
344  log
345  << "\n * mapping [library index @" << cryo.ID()
346  << "] => [optical detector] (" << libOpDetIDmap.size()
347  << " entries):";
348  ;
349  pager = PageBreak;
350  for (auto [ i, opDetID ]: util::enumerate(libOpDetIDmap)) {
351  if (++pager >= PageBreak) {
352  pager = 0;
353  log << "\n ";
354  }
355  log << " [" << i << "] => [" << channelIndex(opDetID) << "];";
356  } // for
357 
358  // print detector to library mapping
359  auto const& opDetLibMap = fOpDetToLibraryIndexMaps[c];
360  pager = PageBreak;
361  log
362  << "\n * mapping [optical detector] => [library index @"
363  << cryo.ID() << "] (" << opDetLibMap.size() << " entries):";
364  ;
365  pager = PageBreak;
366  for (std::size_t i = 0; i < opDetLibMap.size(); ++i) {
367  if (++pager >= PageBreak) {
368  pager = 0;
369  log << "\n ";
370  }
371  log << " [" << i << "] => [" << libraryIndex(opDetLibMap[i]) << "];";
372  }
373 
374  } // for cryostats
375 
376  {
377  log << "\n"
378  << "\nMapping [library index] => [no optical detector] ("
379  << fInvalidLibraryIndexToOpDetMap.size() << " entries):";
380  unsigned int pager = PageBreak;
381  for (std::size_t i = 0; i < fInvalidLibraryIndexToOpDetMap.size(); ++i) {
382  if (++pager >= PageBreak) {
383  pager = 0;
384  log << "\n ";
385  }
386  log << " [" << i << "] => ["
387  << libraryIndex(fInvalidLibraryIndexToOpDetMap[i]) << "];";
388  } // for
389  log << "\n";
390  } // anonymous scope block
391 
392  {
393  log << "\n"
394  << "\nMapping [optical detector] => [no library] ("
395  << fInvalidOpDetToLibraryIndexMap.size() << " entries):";
396  unsigned int pager = PageBreak;
397  for (std::size_t i = 0; i < fInvalidOpDetToLibraryIndexMap.size(); ++i) {
398  if (++pager >= PageBreak) {
399  pager = 0;
400  log << "\n ";
401  }
402  log << " [" << i << "] => ["
403  << channelIndex(fInvalidOpDetToLibraryIndexMap[i]) << "];";
404  } // for
405  log << "\n";
406  } // // anonymous scope block
407 
408 } // phot::ICARUSPhotonMappingTransformations::dumpMapping()
std::vector< LibraryIndexToOpDetMap > fLibraryIndexToOpDetMaps
Library to detector channel mappings, indexed by cryostat number.
LibraryIndexToOpDetMap fInvalidLibraryIndexToOpDetMap
A library-to-detector mapping for invalid points.
std::vector< geo::Vector_t > fTranslations
Translation of the point.
std::vector< int > fChannelShifts
Amount of channel number shifting indexed by cryostat. Not really used.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
OpDetToLibraryIndexMap fInvalidOpDetToLibraryIndexMap
A detector-to-library mapping for invalid points.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
std::vector< OpDetToLibraryIndexMap > fOpDetToLibraryIndexMaps
Detector channel to library mappings, indexed by cryostat number.
geo::Length_t fSwitchPoint
Switch coordinate on x axis [cm].
unsigned int MaxOpChannel() const
Largest optical channel number.
geo::GeometryCore const * fGeom
Detector geometry service provider. Not really used.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
template<typename OutputIndex , typename InputIndex , template< typename...> typename Container>
static Container<InputIndex> phot::ICARUSPhotonMappingTransformations::invertMapping ( Container< OutputIndex > const &  directMap,
std::size_t  size,
InputIndex  invalidIndex 
)
staticprotected

Inverts a given mapping.

Template Parameters
OutputIndexthe output index of the mapping to invert
IndexIndexthe input index of the mapping to invert
Containercontainer used for the mapping (be it std::vector)
Parameters
directMapthe mapping (input index to output index) to be inverted
sizethe total number of output indices (some may be not mapped)
invalidIndexinput index to associate to unmapped output indices
Returns
a mapping (output index to input index) reversing directMap

The resulting, "inverse" mapping has exactly size entries. If the input mapping maps out beyond that, those indices are not mapped back.

template<typename OutputIndex , typename InputIndex , template< typename...> typename Container>
auto phot::ICARUSPhotonMappingTransformations::invertMapping ( Container< OutputIndex > const &  directMap,
std::size_t  size,
InputIndex  invalidIndex 
) -> Container<InputIndex>

Inverts a given mapping.

Template Parameters
OutputIndexthe output index of the mapping to invert
IndexIndexthe input index of the mapping to invert
Containertype of container used for the mapping (be it std::vector)
Parameters
directMapthe mapping (input index to output index) to be inverted
sizethe total number of output indices (some may be not mapped)
invalidIndexthe input index to associate to unmapped output indices
Returns
a mapping (output index to input index) reversing directMap

The resulting, "inverse" mapping has exactly size entries. If the input mapping maps out beyond that, those indices are not mapped back.

Definition at line 332 of file ICARUSPhotonMappingTransformations.h.

336  {
337 
338  OutputIndex const endOutputIndex = size;
339 
340  Container<InputIndex> inverseMap(size, invalidIndex);
341  for (std::size_t i = 0U; i < directMap.size(); ++i) {
342  OutputIndex o = directMap[i];
343  if (o < endOutputIndex) inverseMap[o] = i;
344  }
345  return inverseMap;
346 }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
virtual OpDetID_t phot::ICARUSPhotonMappingTransformations::libraryIndexToOpDet ( geo::Point_t const &  location,
LibraryIndex_t  libIndex 
) const
inlineoverridevirtual

Returns the optical detector ID for the specified library index.

Parameters
locationwhere the scintillation source is in world frame [cm]
libIndexlibrary index to be mapped
Returns
optical detector corresponding to libIndex (as used, e.g., in geo::GeometryCore::OpDetGeoFromOpDet()), or InvalidOpDetID
Exceptions
std::out_of_rangeif input library index can't be handled TODO not implemented this way (yet?)
See Also
opDetToLibraryIndex(), libraryIndicesToOpDets()

Implements phot::IPhotonMappingTransformations.

Definition at line 145 of file ICARUSPhotonMappingTransformations.h.

146  { return libraryIndicesToOpDetsImpl(location)[libIndex]; }
LibraryIndexToOpDetMap const & libraryIndicesToOpDetsImpl(geo::Point_t const &location) const
virtual LibraryIndexToOpDetMap const& phot::ICARUSPhotonMappingTransformations::libraryIndicesToOpDets ( geo::Point_t const &  location) const
inlineoverridevirtual

Returns a map of identifiers of optical detectors for each library index, for the library appropriate around location

Parameters
locationwhere the scintillation source is in world frame [cm]
Returns
optical detector identifiers for all library indices
See Also
opDetsToLibraryIndices(), libraryIndexToOpDet()

We use this mapping when we have information from the visibility library appropriate for a source at the specified location: this information is addressed via a "library index" with the reduced range (i.e. 0 to 179) and we need to know which are the optical detector channels that visibility covers.

For ICARUS, this mapping is expected to be straightforward:

  • [ 0, 179 ] => [ 0, 179 ] if location is in the first cryostat (C:0)
  • [ 0, 179 ] => [ 180, 359 ] if location is in the other one (C:1)

The specified location is used to provide context in a similar fashion as detectorToLibrary() does. It can be used to choose the correct mapping among the available ones.

The returned value is a mapping object (see LibraryIndexToOpDetMap documentation for the interface). If a library index does not map to any optical detector in the library at location (which is unusual!), the optical detector ID corresponding to it is InvalidOpDetID.

Implements phot::IPhotonMappingTransformations.

Definition at line 199 of file ICARUSPhotonMappingTransformations.h.

200  { return libraryIndicesToOpDetsImpl(location); }
LibraryIndexToOpDetMap const & libraryIndicesToOpDetsImpl(geo::Point_t const &location) const
auto phot::ICARUSPhotonMappingTransformations::libraryIndicesToOpDetsImpl ( geo::Point_t const &  location) const
protected

Definition at line 69 of file ICARUSPhotonMappingTransformations.cxx.

70 {
71  geo::CryostatID onCryo = whichCryostat(location);
72  return onCryo
74 } // phot::ICARUSPhotonMappingTransformations::libraryIndicesToOpDetsImpl()
std::vector< LibraryIndexToOpDetMap > fLibraryIndexToOpDetMaps
Library to detector channel mappings, indexed by cryostat number.
LibraryIndexToOpDetMap fInvalidLibraryIndexToOpDetMap
A library-to-detector mapping for invalid points.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
geo::CryostatID whichCryostat(geo::Point_t const &point) const
Returns which cryostat better contain point. Never invalid so far.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
virtual std::size_t phot::ICARUSPhotonMappingTransformations::libraryMappingSize ( geo::Point_t const &  location) const
inlineoverridevirtual

Expected size of the mapping from library to optical detectors.

Parameters
locationwhere the scintillation source is in world frame [cm]
Returns
the expected size of the mapping from library indices to optical detectors
See Also
libraryIndicesToOpDets()

This is effectively the size of the mapping returned by libraryIndicesToOpDets(). It represents how many library indices are provided by the library for the specified location, that is 180.

Implements phot::IPhotonMappingTransformations.

Definition at line 214 of file ICARUSPhotonMappingTransformations.h.

215  { return libraryIndicesToOpDets(location).size();}
virtual LibraryIndexToOpDetMap const & libraryIndicesToOpDets(geo::Point_t const &location) const override
Returns a map of identifiers of optical detectors for each library index, for the library appropriate...
virtual std::size_t phot::ICARUSPhotonMappingTransformations::opDetMappingSize ( ) const
inlineoverridevirtual

Expected number of mappings of optical detector into library index.

Returns
the expected size of the mapping of optical detectors
See Also
opDetsToLibraryIndices()

This is effectively the number of available optical detectors, as well as the size of the mapping as returned by opDetsToLibraryIndices().

Implements phot::IPhotonMappingTransformations.

Definition at line 168 of file ICARUSPhotonMappingTransformations.h.

169  { return opDetsToLibraryIndicesImpl(geo::origin()).size(); }
OpDetToLibraryIndexMap const & opDetsToLibraryIndicesImpl(geo::Point_t const &location) const
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
virtual OpDetToLibraryIndexMap const& phot::ICARUSPhotonMappingTransformations::opDetsToLibraryIndices ( geo::Point_t const &  location) const
inlineoverridevirtual

Returns a map of library indices as function of optical detectors.

Parameters
locationwhere the scintillation source is in world frame [cm]
Returns
library indices for all optical detectors
See Also
opDetToLibraryIndex(), opDetsToLibraryIndices()

Implements phot::IPhotonMappingTransformations.

Definition at line 156 of file ICARUSPhotonMappingTransformations.h.

157  { return opDetsToLibraryIndicesImpl(location); }
OpDetToLibraryIndexMap const & opDetsToLibraryIndicesImpl(geo::Point_t const &location) const
auto phot::ICARUSPhotonMappingTransformations::opDetsToLibraryIndicesImpl ( geo::Point_t const &  location) const
protected

Definition at line 59 of file ICARUSPhotonMappingTransformations.cxx.

60 {
61  geo::CryostatID onCryo = whichCryostat(location);
62  return onCryo
64 } // phot::ICARUSPhotonMappingTransformations::opDetsToLibraryIndicesImpl()
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
OpDetToLibraryIndexMap fInvalidOpDetToLibraryIndexMap
A detector-to-library mapping for invalid points.
std::vector< OpDetToLibraryIndexMap > fOpDetToLibraryIndexMaps
Detector channel to library mappings, indexed by cryostat number.
geo::CryostatID whichCryostat(geo::Point_t const &point) const
Returns which cryostat better contain point. Never invalid so far.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
virtual LibraryIndex_t phot::ICARUSPhotonMappingTransformations::opDetToLibraryIndex ( geo::Point_t const &  location,
OpDetID_t  opDetID 
) const
inlineoverridevirtual

Returns the library index for the specified optical detector.

Parameters
locationwhere the scintillation source is in world frame [cm]
opDetIDoptical detector identifier (as used, e.g., in geo::GeometryCore::OpDetGeoFromOpDet())
Returns
index corresponding to opDetID, or InvalidLibraryIndex
Exceptions
std::out_of_rangeif input optical detector ID can't be handled TODO not implemented this way (yet?)
See Also
opDetFromLibrary()

The mapping reduces the optical detector ID to the corresponding one in the first cryostat.

Implements phot::IPhotonMappingTransformations.

Definition at line 132 of file ICARUSPhotonMappingTransformations.h.

133  { return opDetsToLibraryIndicesImpl(location)[opDetID]; }
OpDetToLibraryIndexMap const & opDetsToLibraryIndicesImpl(geo::Point_t const &location) const
void phot::ICARUSPhotonMappingTransformations::prepareGeometryMapping ( )
protected

Definition at line 78 of file ICARUSPhotonMappingTransformations.cxx.

78  {
79 
80  /*
81  * geometry transformation:
82  * 1. determine the switch coordinate (on x axis) between cryostats
83  * 2. determine the amount of shift required
84  */
85 
86  //
87  // (1) geometry transformation
88  //
89  // (1.1) determine the switch coordinate (on x axis) between cryostats
90 
91  geo::Length_t const C0endX = fGeom->Cryostat(0U).MaxX();
92  geo::Length_t const C1startX = fGeom->Cryostat(1U).MinX();
93  if (C0endX > C1startX) {
94  throw std::runtime_error(
95  "phot::ICARUSPhotonMappingTransformations::prepareGeometryMapping(): "
96  "C:0 ends at x=" + std::to_string(C0endX)
97  + ", C:1 starts at x=" + std::to_string(C1startX)
98  + "... this algorithm does not understand this geometry."
99  );
100  }
101  fSwitchPoint = (C0endX + C1startX) / 2.0; // pick the middle point
102  MF_LOG_DEBUG("ICARUSPhotonMappingTransformations")
103  << "Switching from cryostat 0 to 1 when x > " << fSwitchPoint << " cm";
104 
105  // (1.2) determine the amount of shift required
106  geo::Point_t const refPoint = fGeom->Cryostat(0).BoundingBox().Min();
107  for (geo::CryostatGeo const& cryo: fGeom->IterateCryostats()) {
108  fTranslations.push_back(refPoint - cryo.BoundingBox().Min());
109  } // for all cryostats
110 
111 } // phot::ICARUSPhotonMappingTransformations::prepareGeometryMapping()
double Length_t
Type used for coordinates and distances. They are measured in centimeters.
Definition: geo_vectors.h:137
std::vector< geo::Vector_t > fTranslations
Translation of the point.
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
geo::BoxBoundedGeo const & BoundingBox() const
Returns the bounding box of this cryostat.
Definition: CryostatGeo.h:128
geo::Length_t fSwitchPoint
Switch coordinate on x axis [cm].
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
geo::Point_t Min() const
Returns the corner point with the smallest coordinates.
geo::GeometryCore const * fGeom
Detector geometry service provider. Not really used.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
std::string to_string(WindowPattern const &pattern)
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
void phot::ICARUSPhotonMappingTransformations::prepareLibraryMappings ( LibraryIndexToOpDetMap const &  libraryIndices)
protected

Definition at line 116 of file ICARUSPhotonMappingTransformations.cxx.

117 {
118 
119  /*
120  * 2. library transformation
121  * 1. determine the range of PMT channels in the two cryostats
122  * 2. determine the shift amount (hint: 180)
123  * 3. fill the maps with the shift
124  */
125 
126  //
127  // (2) library transformation
128  //
129  // (2.1) determine the range of PMT channels in the two cryostats
130  /*
131  * This algorithm is a bit cumbersome, but with the complications of optical
132  * detector geometry in LArSoft (which are usually irrelevant for ICARUS)
133  * it's a safer way.
134  * In short: we test for each possible channel in which cryostat its optical
135  * detector is, and extract ranges of channel numbers for each cryostat.
136  * In the end, the result is pretty much known:
137  * 0-179 on C:0 and 180-359 for C:1.
138  */
139  std::vector<lar::util::MinMaxCollector<OpDetID_t>> opDetChannelRangeByCryostat
140  (fGeom->Ncryostats());
141  lar::util::MinMaxCollector<OpDetID_t> opDetChannelRange;
142 
143  unsigned int const maxOpChannel = fGeom->MaxOpChannel();
144  for (unsigned int channel = 0; channel < maxOpChannel; ++channel) {
145 
146  geo::OpDetGeo const& opDet = fGeom->OpDetGeoFromOpChannel(channel);
147  auto const& opDetID = opDet.ID();
148 
149  if (opDetID.isValid) {
150  opDetChannelRange.add(OpDetID_t(channel));
151  opDetChannelRangeByCryostat[opDetID.Cryostat].add(OpDetID_t(channel));
152  }
153 
154  } // for all channels
155 
156  // (2.2) determine the shift amount (hint: 180)
157  fChannelShifts.clear();
158  for (geo::CryostatGeo const& cryo: fGeom->IterateCryostats()) {
159 
160  // sanity checks
161  geo::CryostatID const cid = cryo.ID();
162 
163  auto const& channelRange = opDetChannelRangeByCryostat[cid.Cryostat];
164  if (!channelRange.has_data()) {
165  throw std::runtime_error(
166  "phot::ICARUSPhotonMappingTransformations::prepareLibraryMappings(): "
167  + cid.toString() + " ends up with no optical channels??"
168  );
169  }
170 
171  auto const nChannels = channelRange.max() + 1 - channelRange.min();
172  if ((unsigned int) nChannels != cryo.NOpDet()) {
173  throw std::runtime_error(
174  "phot::ICARUSPhotonMappingTransformations::prepareLibraryMappings(): "
175  + cid.toString() + " expected to have "
176  + std::to_string(cryo.NOpDet()) + " optical channels, we end up with "
177  + std::to_string(nChannels) + " ("
178  + std::to_string(channelRange.min()) + " - "
179  + std::to_string(channelRange.max()) + ")"
180  );
181  } // if
182 
183  // relative shift with respect to the first cryostat:
184  fChannelShifts.push_back
185  (channelRange.min() - opDetChannelRangeByCryostat.front().min());
186 
187  } // for cryostats
188 
189 
190  // (2.3) fill the maps with the shift
191 
192  // (2.3.1) std::vector<LibraryIndexToOpDetMap> fLibraryIndexToOpDetMaps
193  // mapping library index => optical detector ID
194  // indexed by cryostat number of the source
195  //
196  // For ICARUS, this mapping is expected to be straightforward:
197  // * [ 0, 179 ] => [ 0, 179 ] if `location` is in the first cryostat (C:0)
198  // * [ 0, 179 ] => [ 180, 359 ] if `location` is in the other one (C:1)
199  //
200  fLibraryIndexToOpDetMaps.clear();
201  for (geo::CryostatGeo const& cryo: fGeom->IterateCryostats()) {
202 
203  // this is the library for sources in cryostat `cryo`;
204  // it is positioned at `cryo.ID().Cryostat` in `fLibOpDetIDmaps`;
205  // the library is expected to have only 180 entries,
206  // one per optical detector within `cryo`
207 
208  auto const nChannels = cryo.NOpDet();
209  if (libraryIndices.size() != nChannels) {
210  throw std::runtime_error(
211  "phot::ICARUSPhotonMappingTransformations::prepareLibraryMappings(): "
212  "the internal mapping should cover " + std::to_string(nChannels)
213  + " channels but it covers " + std::to_string(libraryIndices.size())
214  + " instead."
215  );
216  }
217 
218  auto const nFirst = fChannelShifts[cryo.ID().Cryostat];
219  LibraryIndexToOpDetMap libraryIndexToOpDetMap { libraryIndices }; // copy
220  for (auto& c: libraryIndexToOpDetMap) c += nFirst;
221 
222  fLibraryIndexToOpDetMaps.push_back(std::move(libraryIndexToOpDetMap));
223 
224  } // for channel range
225 
226  // if the position is invalid, no library data is actually present,
227  // and the mapping is moot; we choose the rank of this mootness to be the same
228  // as the first valid mapping
231  (fLibraryIndexToOpDetMaps.front().size(), InvalidOpDetID);
232 
233  // (2.3.2) std::vector<OpDetToLibraryIndexMap> fOpDetToLibraryIndexMaps
234  // mapping detector optical ID => library index
235  //
236  // For ICARUS, this mapping is expected to be:
237  // * if `location` is in the first cryostat (C:0):
238  // * [ 0, 179 ] => [ 0, 179 ]
239  // * [ 180, 359 ] => invalid indices
240  // * if `location` is in the second cryostat (C:1):
241  // * [ 0, 179 ] => invalid indices
242  // * [ 180, 359 ] => [ 0, 179 ]
243  //
244  fOpDetToLibraryIndexMaps.clear();
245  for (auto const& libToOpDetMap: fLibraryIndexToOpDetMaps) {
246 
247  fOpDetToLibraryIndexMaps.push_back
248  (invertMapping(libToOpDetMap, maxOpChannel, InvalidLibraryIndex));
249 
250  } // for each library mapping
251 
254 
255 } // phot::ICARUSPhotonMappingTransformations::prepareMappings()
std::vector< LibraryIndexToOpDetMap > fLibraryIndexToOpDetMaps
Library to detector channel mappings, indexed by cryostat number.
LibraryIndexToOpDetMap fInvalidLibraryIndexToOpDetMap
A library-to-detector mapping for invalid points.
std::vector< int > fChannelShifts
Amount of channel number shifting indexed by cryostat. Not really used.
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
OpDetToLibraryIndexMap fInvalidOpDetToLibraryIndexMap
A detector-to-library mapping for invalid points.
Keeps track of the minimum and maximum value we observed.
static constexpr LibraryIndex_t InvalidLibraryIndex
Value used for an invalid library index.
std::vector< OpDetToLibraryIndexMap > fOpDetToLibraryIndexMaps
Detector channel to library mappings, indexed by cryostat number.
static constexpr OpDetID_t InvalidOpDetID
Value used to identify an invalid optical detector.
std::string toString() const
Human-readable representation of the cryostat ID.
Definition: geo_types.h:247
unsigned int MaxOpChannel() const
Largest optical channel number.
std::vector< OpDetID_t > LibraryIndexToOpDetMap
Type describing the mapping of optical detectors into library indices.
geo::GeometryCore const * fGeom
Detector geometry service provider. Not really used.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
int OpDetID_t
Type describing a optical detector ID.
std::string to_string(WindowPattern const &pattern)
geo::OpDetID const & ID() const
Returns the geometry ID of this optical detector.
Definition: OpDetGeo.h:72
static Container< InputIndex > invertMapping(Container< OutputIndex > const &directMap, std::size_t size, InputIndex invalidIndex)
Inverts a given mapping.
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void phot::ICARUSPhotonMappingTransformations::prepareMappings ( LibraryIndexToOpDetMap const &  libraryIndices)
protected

Extracts the necessary information for mapping from the geometry.

Definition at line 260 of file ICARUSPhotonMappingTransformations.cxx.

261 {
262 
263  /*
264  * 1. geometry transformation:
265  * 1. determine the switch coordinate (on x axis) between cryostats
266  * 2. determine the amount of shift required
267  * 2. library transformation
268  * 1. determine the range of PMT channels in the two cryostats
269  * 2. determine the shift amount (hint: 180)
270  * 3. fill the maps with the shift
271  */
272 
273  mf::LogInfo("ICARUSPhotonMappingTransformations")
274  << "Photon visibility mapping tool: 'ICARUSPhotonMappingTransformations'";
275 
276  //
277  // (1) geometry transformation
278  //
280 
281  //
282  // (2) library transformation
283  //
284  prepareLibraryMappings(libraryIndices);
285 
286  // debug:
287  if (fDumpMapping) dumpMapping();
288 
289 } // phot::ICARUSPhotonMappingTransformations::prepareMappings()
void dumpMapping() const
Writes the current mapping information into the console. Debug stuff.
bool fDumpMapping
Whether to dump mapping on initialization.
void prepareLibraryMappings(LibraryIndexToOpDetMap const &libraryIndices)
geo::CryostatID phot::ICARUSPhotonMappingTransformations::whichCryostat ( geo::Point_t const &  point) const
inlineprotected

Returns which cryostat better contain point. Never invalid so far.

Definition at line 262 of file ICARUSPhotonMappingTransformations.h.

263  { return geo::CryostatID{ (point.X() > fSwitchPoint)? 1U: 0U }; }
geo::Length_t fSwitchPoint
Switch coordinate on x axis [cm].
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190

Member Data Documentation

std::vector<int> phot::ICARUSPhotonMappingTransformations::fChannelShifts
protected

Amount of channel number shifting indexed by cryostat. Not really used.

Total number of optical detector channels.

Definition at line 247 of file ICARUSPhotonMappingTransformations.h.

bool phot::ICARUSPhotonMappingTransformations::fDumpMapping = false
protected

Whether to dump mapping on initialization.

Definition at line 226 of file ICARUSPhotonMappingTransformations.h.

geo::GeometryCore const* phot::ICARUSPhotonMappingTransformations::fGeom = nullptr
protected

Detector geometry service provider. Not really used.

Definition at line 233 of file ICARUSPhotonMappingTransformations.h.

LibraryIndexToOpDetMap phot::ICARUSPhotonMappingTransformations::fInvalidLibraryIndexToOpDetMap
protected

A library-to-detector mapping for invalid points.

Definition at line 251 of file ICARUSPhotonMappingTransformations.h.

OpDetToLibraryIndexMap phot::ICARUSPhotonMappingTransformations::fInvalidOpDetToLibraryIndexMap
protected

A detector-to-library mapping for invalid points.

Definition at line 255 of file ICARUSPhotonMappingTransformations.h.

std::vector<LibraryIndexToOpDetMap> phot::ICARUSPhotonMappingTransformations::fLibraryIndexToOpDetMaps
protected

Library to detector channel mappings, indexed by cryostat number.

Definition at line 249 of file ICARUSPhotonMappingTransformations.h.

unsigned int phot::ICARUSPhotonMappingTransformations::fNOpDetChannels
protected

Definition at line 245 of file ICARUSPhotonMappingTransformations.h.

std::vector<OpDetToLibraryIndexMap> phot::ICARUSPhotonMappingTransformations::fOpDetToLibraryIndexMaps
protected

Detector channel to library mappings, indexed by cryostat number.

Definition at line 253 of file ICARUSPhotonMappingTransformations.h.

geo::Length_t phot::ICARUSPhotonMappingTransformations::fSwitchPoint
protected

Switch coordinate on x axis [cm].

Definition at line 240 of file ICARUSPhotonMappingTransformations.h.

std::vector<geo::Vector_t> phot::ICARUSPhotonMappingTransformations::fTranslations
protected

Translation of the point.

Definition at line 239 of file ICARUSPhotonMappingTransformations.h.


The documentation for this class was generated from the following files: