All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
icarus::trigger::SlidingWindowDefinitionAlg Class Reference

Groups optical detector channels into windows based on position. More...

#include <SlidingWindowDefinitionAlg.h>

Public Types

using WindowChannels_t = icarus::trigger::TriggerWindowChannels_t
 Type of optical detector channel list in a window. More...
 
using WindowDefs_t = icarus::trigger::TriggerWindowDefs_t
 Definition of all windows. More...
 

Public Member Functions

 SlidingWindowDefinitionAlg (geo::GeometryCore const &geom, std::string logCategory="SlidingWindowDefinitionAlg")
 Constructor: complete algorithm setup. More...
 
WindowDefs_t makeWindows (unsigned int windowSize, unsigned int windowStride) const
 Performs the calculation and returns the sliding window composition. More...
 
WindowDefs_t operator() (unsigned int windowSize, unsigned int windowStride) const
 
WindowDefs_t makeWindows (unsigned int windowSize) const
 Performs the calculation and returns the sliding window composition. More...
 
WindowDefs_t operator() (unsigned int windowSize) const
 

Private Attributes

std::string const fLogCategory
 Message facility stream category for output. More...
 
geo::GeometryCore const & fGeom
 Geometry service provider. More...
 

Detailed Description

Groups optical detector channels into windows based on position.

This algorithm groups all the optical detectors in the specified detector geometry description into "sliding windows".

Each optical detector "wall" (detectors at the same drift coordinate, that is on the same plane) is sliced in windows of a given size (windowSize, the number of optical detector channels within) starting one after the other at fixed intervals (windowStride).

For example, a partition with window size 30 channels and stride also 30 channels on a wall of 90 optical detector channels will create 3 windows with 30 channels each. A splitting with size 30 channels but stride only 15 channels will create 5 windows of 30 channels each, which overlap (like in 0-29, 15-44, 30-59, 45-74 and 60-89).

The windows are returned in the formats defined in icaruscode/PMT/Trigger/Algorithms/SlidingWindowDefs.h, that is a list of windows, each being a list of optical detector channels.

Algorithm details

Optical detectors are split into "walls" and within each wall into "towers" (a wall being a set of optical detectors at the same drift coordinate, i.e. on a plane, and a tower being a set of detector in a wall which share the horizontal position but are piled in the vertical one, y). The task of separating the detectors in walls and towers is delegated to the algorithm icarus::trigger::PMTverticalSlicingAlg.

Each wall is processed separately. The towers in the wall are sorted in the non-vertical direction (in ICARUS they will have a pattern of 2 channels, 3 channels, 3 channels, 2 channels, repeated 9 times), and the windows are created starting from one end. Towers are progressively added to the window until the window reaches the desided size (if it overshoots it, the window size is not compatible with the geometry and an exception is thrown). The process is repeated for each window, starting with the first tower, then the tower starting after windowStride optical detectors, then the tower starting after twice windowStride detectors, and so on, until a a window is reached that can't be completed because we ran out of towers. If there is no tower starting at the exact multiple of windowStride, the stride parameter is not compatible with the detector geometry, and an exception is thrown.

Definition at line 83 of file SlidingWindowDefinitionAlg.h.

Member Typedef Documentation

Type of optical detector channel list in a window.

Definition at line 102 of file SlidingWindowDefinitionAlg.h.

Definition of all windows.

Definition at line 105 of file SlidingWindowDefinitionAlg.h.

Constructor & Destructor Documentation

icarus::trigger::SlidingWindowDefinitionAlg::SlidingWindowDefinitionAlg ( geo::GeometryCore const &  geom,
std::string  logCategory = "SlidingWindowDefinitionAlg" 
)
inline

Constructor: complete algorithm setup.

Parameters
geomLArSoft geometry service provider
logCategorytag to use for messages to message facility service

Definition at line 156 of file SlidingWindowDefinitionAlg.h.

160  : fLogCategory(std::move(logCategory))
161  , fGeom(geom)
162  {}
geo::GeometryCore const & fGeom
Geometry service provider.
std::string const fLogCategory
Message facility stream category for output.

Member Function Documentation

auto icarus::trigger::SlidingWindowDefinitionAlg::makeWindows ( unsigned int  windowSize,
unsigned int  windowStride 
) const

Performs the calculation and returns the sliding window composition.

Parameters
windowSizenumber of optical detectors in each window
windowStridenew window every windowStride optical detectors

Definition at line 37 of file SlidingWindowDefinitionAlg.cxx.

39 {
40  /*
41  * 1. compute the vertical PMT towers in each separate optical detector plane
42  * 2. fill the windows by counting channels (i.e. op. det.)
43  */
45 
46  //
47  // 1. compute the vertical PMT towers in each separate optical detector plane
48  //
49  PMTverticalSlicingAlg slicerAlg(fLogCategory);
51  for (geo::CryostatGeo const& cryo: fGeom.IterateCryostats())
52  slicerAlg.appendCryoSlices(slices, cryo);
53 
54  //
55  // 2. fill the windows by counting channels (i.e. optical detectors)
56  //
57  WindowDefs_t windows;
58 
59  for (PMTverticalSlicingAlg::PMTtowerOnPlane_t const& planeSlices: slices) {
60 
61  auto itSlice = planeSlices.begin();
62  auto const send = planeSlices.end();
63  while (itSlice != send) {
64 
65  mf::LogTrace(fLogCategory) << "Assembling window #" << windows.size();
66 
67  WindowDefs_t::value_type window;
68  window.reserve(windowSize);
69 
70  std::optional<decltype(itSlice)> nextStart;
71  unsigned int nChannels = 0U;
72  while (nChannels < windowSize) {
73  if (itSlice == send) break;
74 
75  // aside: check if this is the right place to start the next window
76  if (nChannels == windowStride) {
77  mf::LogTrace(fLogCategory)
78  << " (next window will start from this slice)";
79  nextStart = itSlice;
80  }
81  else if ((nChannels > windowStride) && !nextStart) {
82  throw cet::exception("SlidingWindowDefinitionAlg")
83  << "Unable to start a new window " << windowStride
84  << " channels after window #" << windows.size()
85  << " (next slice starts " << nChannels << " channels after)\n";
86  }
87 
88  mf::LogTrace(fLogCategory)
89  << " adding " << itSlice->size() << " channels to existing "
90  << nChannels;
91  for (geo::OpDetGeo const* opDet: *itSlice) {
92  geo::OpDetID const& id = opDet->ID();
93  raw::Channel_t const channel
94  = fGeom.OpDetFromCryo(id.OpDet, id.Cryostat);
95  mf::LogTrace(fLogCategory)
96  << " * " << id << " (channel " << channel << ")";
97  window.push_back(channel);
98  } // for channels in slice
99  nChannels += (itSlice++)->size();
100  } // while
101  if (nChannels == windowStride) nextStart = itSlice;
102  assert(nextStart);
103 
104  if (nChannels < windowSize) {
105  if (!windows.empty()) {
106  // if the last window can't be completed, it's still fine for us
107  mf::LogTrace(fLogCategory)
108  << " ... couldn't complete the last " << windowSize
109  << "-channel window: only " << nChannels << " channels collected";
110  break;
111  }
112  } // if missing windows
113  if (nChannels != windowSize) {
114  throw cet::exception("SlidingWindowDefinitionAlg")
115  << "Definition of one window yielded " << nChannels
116  << " elements (window should be of size " << windowSize
117  << " and with stride " << windowStride << ").\n";
118  }
119 
120  windows.push_back(std::move(window));
121 
122  itSlice = nextStart.value();
123  } // for all slices
124  } // for all windows
125  mf::LogTrace(fLogCategory)
126  << "SlidingWindowTrigger defined " << windows.size() << " windows.";
127 
128  return windows;
129 } // icarus::trigger::SlidingWindowDefinitionAlg::makeWindows()
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
icarus::trigger::TriggerWindowDefs_t WindowDefs_t
Definition of all windows.
unsigned int OpDetFromCryo(unsigned int o, unsigned int c) const
Get unique opdet number from cryo and internal count.
geo::GeometryCore const & fGeom
Geometry service provider.
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
std::string const fLogCategory
Message facility stream category for output.
The data type to uniquely identify a optical detector.
Definition: geo_types.h:297
std::vector< PMTtowerOnPlane_t > Slices_t
Type of PMT towers, per plane.
std::vector< PMTtower_t > PMTtowerOnPlane_t
Type of list of PMT towers on a single optical detector plane.
Algorithm clustering PMT according to their position.
WindowDefs_t icarus::trigger::SlidingWindowDefinitionAlg::makeWindows ( unsigned int  windowSize) const
inline

Performs the calculation and returns the sliding window composition.

Parameters
windowSizenumber of optical detectors in each window

Windows are contiguous and not overlapping.

Definition at line 141 of file SlidingWindowDefinitionAlg.h.

142  { return makeWindows(windowSize, windowSize); }
WindowDefs_t makeWindows(unsigned int windowSize, unsigned int windowStride) const
Performs the calculation and returns the sliding window composition.
WindowDefs_t icarus::trigger::SlidingWindowDefinitionAlg::operator() ( unsigned int  windowSize,
unsigned int  windowStride 
) const
inline

Definition at line 129 of file SlidingWindowDefinitionAlg.h.

130  { return makeWindows(windowSize, windowStride); }
WindowDefs_t makeWindows(unsigned int windowSize, unsigned int windowStride) const
Performs the calculation and returns the sliding window composition.
WindowDefs_t icarus::trigger::SlidingWindowDefinitionAlg::operator() ( unsigned int  windowSize) const
inline

Definition at line 144 of file SlidingWindowDefinitionAlg.h.

145  { return makeWindows(windowSize); }
WindowDefs_t makeWindows(unsigned int windowSize, unsigned int windowStride) const
Performs the calculation and returns the sliding window composition.

Member Data Documentation

geo::GeometryCore const& icarus::trigger::SlidingWindowDefinitionAlg::fGeom
private

Geometry service provider.

Definition at line 95 of file SlidingWindowDefinitionAlg.h.

std::string const icarus::trigger::SlidingWindowDefinitionAlg::fLogCategory
private

Message facility stream category for output.

Definition at line 88 of file SlidingWindowDefinitionAlg.h.


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