All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChannelToWireMap.cxx
Go to the documentation of this file.
1 /**
2  * @file icarusalg/Geometry/details/ChannelToWireMap.cxx
3  * @brief Channel-to-wire mapping data structure (implementation file).
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date October 16, 2019
6  * @see `icarusalg/Geometry/details/ChannelToWireMap.h`
7  */
8 
9 // library header
11 
12 // C/C++ libraries
13 #include <iterator> // std::prev()
14 #include <algorithm> // std::upper_bound(), std::find_if()
15 
16 
17 //------------------------------------------------------------------------------
19  (raw::ChannelID_t channel) const -> ChannelsInROPStruct const*
20 {
21  // find the first element whose channel is _not_ included
22  auto const dbegin = fROPfirstChannel.begin(), dend = fROPfirstChannel.end();
23  auto const iNextData = std::upper_bound
24  (dbegin, dend, channel, ChannelsInROPStruct::Compare{});
25  assert(iNextData != dbegin);
26 
27  return ((iNextData == dend) && (channel >= endChannel()))
28  ? nullptr: &*std::prev(iNextData);
29 
30 } // icarus::details::ChannelToWireMap::find(raw::ChannelID_t)
31 
32 //------------------------------------------------------------------------------
34  (readout::ROPID const& ropid) const -> ChannelsInROPStruct const*
35 {
36  // find the first element whose channel is _not_ included
37  auto const dend = fROPfirstChannel.end();
38  auto const iData = std::find_if(
39  fROPfirstChannel.begin(), dend,
40  [&ropid](ChannelsInROPStruct const& data){ return data.ropid == ropid; }
41  );
42  return (iData == dend)? nullptr: &*iData;
43 } // icarus::details::ChannelToWireMap::find(readout::ROPID)
44 
45 
46 // -----------------------------------------------------------------------------
48  fROPfirstChannel.clear();
50 } // icarus::details::ChannelToWireMap::clear()
51 
52 
53 // -----------------------------------------------------------------------------
Channel-to-wire mapping data structure.
ChannelsInROPStruct const * find(raw::ChannelID_t channel) const
Returns data of the ROP including channel, nullptr if none.
void clear()
Resets the data of the map to like just constructed.
raw::ChannelID_t fEndChannel
ID of the first invalid channel.
Class identifying a set of planes sharing readout channels.
Compares with a channel ID (std::less&lt;&gt;).
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
std::vector< ChannelsInROPStruct > fROPfirstChannel
Collection of channel ROP channel information, sorted by first channel.