LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS > Class Template Reference

CountersMap with access optimized for Hough Transform algorithm. More...

#include "HoughBaseAlg.h"

Inheritance diagram for cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >:
lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >

Public Types

using CounterMap_t = HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >
 This class. More...
 
using Base_t = lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >
 Base class. More...
 
using BaseMap_t = typename Base_t::BaseMap_t
 
using Allocator_t = typename Base_t::Allocator_t
 
using Key_t = typename Base_t::Key_t
 
using SubCounter_t = typename Base_t::SubCounter_t
 
using CounterBlock_t = typename Base_t::CounterBlock_t
 
using const_iterator = typename Base_t::const_iterator
 
using PairValue_t = std::pair< const_iterator, SubCounter_t >
 Pair identifying a counter and its current value. More...
 
using Counter_t = COUNTER
 type of the single counter More...
 
using value_type = std::pair< const Key_t, SubCounter_t >
 
STL type definitions
using mapped_type = SubCounter_t
 type of the single counter More...
 
using allocator_type = Allocator_t
 type of the single counter More...
 

Public Member Functions

 HoughTransformCounters ()
 Default constructor (empty map) More...
 
 HoughTransformCounters (Allocator_t alloc)
 Constructor, specifies an allocator. More...
 
SubCounter_t set (Key_t key, SubCounter_t value)
 Sets the specified counter to a count value. More...
 
SubCounter_t increment (Key_t key)
 Increments by 1 the specified counter. More...
 
SubCounter_t decrement (Key_t key)
 Decrements by 1 the specified counter. More...
 
SubCounter_t set (Key_t key_begin, Key_t key_end, SubCounter_t value)
 Sets the specified range of counters to a count value. More...
 
void increment (Key_t key_begin, Key_t key_end)
 Increments by 1 the specified range of counters. More...
 
PairValue_t increment_and_get_max (Key_t key_begin, Key_t key_end)
 Increments by 1 the specified counters and returns the maximum. More...
 
PairValue_t increment_and_get_max (Key_t key_begin, Key_t key_end, SubCounter_t current_max)
 Increments by 1 the specified counters and returns the maximum. More...
 
void decrement (Key_t key_begin, Key_t key_end)
 Decrements by 1 the specified range of counters. More...
 
PairValue_t get_max (SubCounter_t current_max) const
 Returns the largest counter. More...
 
PairValue_t get_max () const
 Increments by 1 the specified counters and returns the maximum. More...
 
SubCounter_t operator[] (Key_t key) const
 Read-only access to an element; returns 0 if no counter is present. More...
 
bool empty () const
 Returns whether the map has no counters. More...
 
std::make_unsigned< Key_t >::type n_counters () const
 Returns the number of allocated counters. More...
 
template<typename OALLOC >
bool is_equal (const std::map< Key_t, SubCounter_t, std::less< Key_t >, OALLOC > &to, Key_t &first_difference) const
 Returns whether the counters in this map are equivalent to another. More...
 
template<typename OALLOC >
bool is_equal (const std::map< Key_t, SubCounter_t, std::less< Key_t >, OALLOC > &to) const
 Returns whether the counters in this map are equivalent to another. More...
 
Iterators (experimental)
const_iterator begin () const
 Returns an iterator to the begin of the counters. More...
 
const_iterator end () const
 Returns an iterator past-the-end of the counters. More...
 

Static Public Attributes

static constexpr size_t NCounters = Traits_t::NCounters
 Number of counters in one counter block. More...
 
static constexpr size_t NSubcounters = NCounters * SUBCOUNTERS
 Number of subcounters in one counter block. More...
 

Protected Types

using CounterKey_t = typename Base_t::CounterKey_t
 
using BlockKey_t = Key_t
 type of block key More...
 
using CounterIndex_t = typename std::make_unsigned< Key_t >::type
 type of index in the block More...
 

Protected Member Functions

Counter_t GetCounter (CounterKey_t key) const
 Returns the value of the counter at the specified split key. More...
 
SubCounter_t GetSubCounter (CounterKey_t key) const
 Returns the value of the subcounter at the specified split key. More...
 
Counter_tGetOrCreateCounter (CounterKey_t key)
 Returns the counter at the specified split key. More...
 

Static Protected Member Functions

static CounterKey_t SplitKey (Key_t key)
 Returns a split key corresponding to the specified key. More...
 
static const_iterator make_const_iterator (typename BaseMap_t::const_iterator it, size_t ix)
 Creates a const_iterator (useful in derived classes) More...
 

Protected Attributes

BaseMap_t counter_map
 the actual data structure for counters More...
 

Private Member Functions

SubCounter_t unchecked_set_range (Key_t key_begin, Key_t key_end, SubCounter_t value, typename BaseMap_t::iterator start)
 
SubCounter_t unchecked_set_range (Key_t key_begin, Key_t key_end, SubCounter_t value)
 
PairValue_t unchecked_add_range_max (Key_t key_begin, Key_t key_end, SubCounter_t delta, typename BaseMap_t::iterator start, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
 
PairValue_t unchecked_add_range_max (Key_t key_begin, Key_t key_end, SubCounter_t delta, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
 

Detailed Description

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
class cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >

CountersMap with access optimized for Hough Transform algorithm.

Parameters
KEYthe type of the key of the counters map
COUNTERthe type of a basic counter (can be signed or unsigned)
BLOCKSIZEthe number of counters in a cluster
ALLOCallocator for the underlying STL map
SUBCOUNTERSsplit each counter in subcounters (not implemented yet)
See also
CountersMap

In addition to the standard CountersMap interface, a special range increment, increment with max detection and decrement methods are provided.

Definition at line 279 of file HoughBaseAlg.h.

Member Typedef Documentation

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::Allocator_t = typename Base_t::Allocator_t

Definition at line 288 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
using lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::allocator_type = Allocator_t
inherited

type of the single counter

Definition at line 171 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::Base_t = lar::CountersMap<KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS>

Base class.

Definition at line 284 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::BaseMap_t = typename Base_t::BaseMap_t

Definition at line 287 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
using lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::BlockKey_t = Key_t
protectedinherited

type of block key

Definition at line 270 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::const_iterator = typename Base_t::const_iterator

Definition at line 292 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
using lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::Counter_t = COUNTER
inherited

type of the single counter

Definition at line 139 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterBlock_t = typename Base_t::CounterBlock_t

Definition at line 291 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
using lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterIndex_t = typename std::make_unsigned<Key_t>::type
protectedinherited

type of index in the block

Definition at line 272 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterKey_t = typename Base_t::CounterKey_t
protected

Definition at line 433 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterMap_t = HoughTransformCounters<KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS>

This class.

Definition at line 282 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::Key_t = typename Base_t::Key_t

Definition at line 289 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
using lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::mapped_type = SubCounter_t
inherited

type of the single counter

Definition at line 170 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::PairValue_t = std::pair<const_iterator, SubCounter_t>

Pair identifying a counter and its current value.

Definition at line 295 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
using cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::SubCounter_t = typename Base_t::SubCounter_t

Definition at line 290 of file HoughBaseAlg.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
using lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::value_type = std::pair<const Key_t, SubCounter_t>
inherited

Definition at line 175 of file CountersMap.h.

Constructor & Destructor Documentation

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::HoughTransformCounters ( )
inline

Default constructor (empty map)

Definition at line 298 of file HoughBaseAlg.h.

298 : Base_t() {}
lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS > Base_t
Base class.
Definition: HoughBaseAlg.h:284
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::HoughTransformCounters ( Allocator_t  alloc)
inline

Constructor, specifies an allocator.

Definition at line 301 of file HoughBaseAlg.h.

301 : Base_t(alloc) {}
lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS > Base_t
Base class.
Definition: HoughBaseAlg.h:284

Member Function Documentation

template<typename K , typename C , size_t S, typename A , unsigned int SUB>
CountersMap< K, C, S, A, SUB >::const_iterator lar::CountersMap< K, C, S, A, SUB >::begin ( ) const
inlineinherited

Returns an iterator to the begin of the counters.

Definition at line 525 of file CountersMap.h.

527  {
528  return const_iterator{counter_map.begin(), 0};
529  }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
SubCounter_t cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::decrement ( Key_t  key)
inline

Decrements by 1 the specified counter.

Parameters
keykey of the counter to be decreased
Returns
new value of the counter

Definition at line 323 of file HoughBaseAlg.h.

Referenced by cluster::HoughTransform::DoAddPointReturnMax().

323 { return Base_t::decrement(key); }
SubCounter_t decrement(Key_t key)
Decrements by 1 the specified counter.
Definition: CountersMap.h:519
template<typename K , typename C , size_t S, typename A , unsigned int SC>
void cluster::HoughTransformCounters< K, C, S, A, SC >::decrement ( Key_t  key_begin,
Key_t  key_end 
)
inline

Decrements by 1 the specified range of counters.

Parameters
key_beginkey of the first counter to be increased
key_endkey of the first counter not to be increased
See also
increment()

Definition at line 132 of file HoughBaseAlg.cxx.

134 {
135  unchecked_add_range_max(key_begin, key_end, -1, std::numeric_limits<SubCounter_t>::max());
136 } // cluster::HoughTransformCounters<>::decrement(begin, end)
PairValue_t unchecked_add_range_max(Key_t key_begin, Key_t key_end, SubCounter_t delta, typename BaseMap_t::iterator start, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
bool lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::empty ( ) const
inlineinherited

Returns whether the map has no counters.

Definition at line 228 of file CountersMap.h.

228 { return counter_map.empty(); }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
template<typename K , typename C , size_t S, typename A , unsigned int SUB>
CountersMap< K, C, S, A, SUB >::const_iterator lar::CountersMap< K, C, S, A, SUB >::end ( ) const
inlineinherited

Returns an iterator past-the-end of the counters.

Definition at line 532 of file CountersMap.h.

534  {
535  return const_iterator{counter_map.end(), 0};
536  }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
template<typename K , typename C , size_t S, typename A , unsigned int SC>
cluster::HoughTransformCounters< K, C, S, A, SC >::PairValue_t cluster::HoughTransformCounters< K, C, S, A, SC >::get_max ( SubCounter_t  current_max) const

Returns the largest counter.

Parameters
current_maxonly counters larger than this will be considered
Returns
pair with an iterator to the largest counter and its value
See also
get_max(), increment_and_get_max(Key_t, Key_t)

All counters are parsed, and the first one with the largest count is returned. The return value consist of a pair: the second is the largest counter value, the first member is the constant iterator pointing to the first (lowest key) counter with that (get its key with const_iterator::key() method).

This method does not update the maximum if it's not (strictly) larger than current_max. If no such a maximum is found, the maximum in the return value is equal to current_max, while the iterator points to the end of the map (end()).

Definition at line 140 of file HoughBaseAlg.cxx.

References util::cend(), and util::end().

141 {
143 
144  typename BaseMap_t::const_iterator iCBlock = Base_t::counter_map.begin(),
145  cend = Base_t::counter_map.end();
146  while (iCBlock != cend) {
147  const CounterBlock_t& block = iCBlock->second;
148  for (size_t index = 0; index < block.size(); ++index) {
149  if (block[index] > max.second)
150  max = {Base_t::make_const_iterator(iCBlock, index), block[index]};
151  ++iCBlock;
152  } // for elements in this block
153  } // while blocks
154  return max;
155 } // cluster::HoughTransformCounters<>::get_max(SubCounter_t)
const_iterator end() const
Returns an iterator past-the-end of the counters.
Definition: CountersMap.h:532
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
intermediate_table::const_iterator const_iterator
std::pair< const_iterator, SubCounter_t > PairValue_t
Pair identifying a counter and its current value.
Definition: HoughBaseAlg.h:295
static const_iterator make_const_iterator(typename BaseMap_t::const_iterator it, size_t ix)
Creates a const_iterator (useful in derived classes)
Definition: CountersMap.h:374
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
typename Base_t::CounterBlock_t CounterBlock_t
Definition: HoughBaseAlg.h:291
template<typename K , typename C , size_t S, typename A , unsigned int SC>
cluster::HoughTransformCounters< K, C, S, A, SC >::PairValue_t cluster::HoughTransformCounters< K, C, S, A, SC >::get_max ( ) const
inline

Increments by 1 the specified counters and returns the maximum.

Parameters
current_maxonly counters larger than this will be considered
Returns
pair with an iterator to the largest counter and its value
See also
get_max(SubCounter_t), increment_and_get_max(Key_t, Key_t)

This method works like get_max() method, except that it does not update the maximum if it's not (strictly) larger than current_max. If no such a maximum is found, the maximum in the return value is equal to current_max, while the iterator points to the end of the map (end()).

Definition at line 159 of file HoughBaseAlg.cxx.

160 {
161  return get_max(std::numeric_limits<SubCounter_t>::max());
162 }
PairValue_t get_max() const
Increments by 1 the specified counters and returns the maximum.
template<typename K , typename C , size_t S, typename A , unsigned int SUB>
CountersMap< K, C, S, A, SUB >::Counter_t lar::CountersMap< K, C, S, A, SUB >::GetCounter ( CounterKey_t  key) const
inlineprotectedinherited

Returns the value of the counter at the specified split key.

Definition at line 607 of file CountersMap.h.

References lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterKey_t::block, and lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterKey_t::counter.

609  {
610  typename BaseMap_t::const_iterator iBlock = counter_map.find(key.block);
611  return (iBlock == counter_map.end()) ? 0 : iBlock->second[key.counter];
612  } // CountersMap<>::GetCounter() const
intermediate_table::const_iterator const_iterator
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
template<typename K , typename C , size_t S, typename A , unsigned int SUB>
CountersMap< K, C, S, A, SUB >::Counter_t & lar::CountersMap< K, C, S, A, SUB >::GetOrCreateCounter ( CounterKey_t  key)
inlineprotectedinherited

Returns the counter at the specified split key.

Definition at line 616 of file CountersMap.h.

References lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterKey_t::block, and lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::CounterKey_t::counter.

617  {
618  return counter_map[key.block][key.counter];
619  }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
SubCounter_t lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::GetSubCounter ( CounterKey_t  key) const
inlineprotectedinherited

Returns the value of the subcounter at the specified split key.

Definition at line 365 of file CountersMap.h.

365 { return GetCounter(key); }
Counter_t GetCounter(CounterKey_t key) const
Returns the value of the counter at the specified split key.
Definition: CountersMap.h:607
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
SubCounter_t cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::increment ( Key_t  key)
inline

Increments by 1 the specified counter.

Parameters
keykey of the counter to be increased
Returns
new value of the counter

Definition at line 316 of file HoughBaseAlg.h.

316 { return Base_t::increment(key); }
SubCounter_t increment(Key_t key)
Increments by 1 the specified counter.
Definition: CountersMap.h:512
template<typename K , typename C , size_t S, typename A , unsigned int SC>
void cluster::HoughTransformCounters< K, C, S, A, SC >::increment ( Key_t  key_begin,
Key_t  key_end 
)
inline

Increments by 1 the specified range of counters.

Parameters
key_beginkey of the first counter to be increased
key_endkey of the first counter not to be increased
See also
decrement(), increment_and_get_max()

Definition at line 125 of file HoughBaseAlg.cxx.

127 {
128  unchecked_add_range_max(key_begin, key_end, +1, std::numeric_limits<SubCounter_t>::max());
129 } // cluster::HoughTransformCounters<>::increment(begin, end)
PairValue_t unchecked_add_range_max(Key_t key_begin, Key_t key_end, SubCounter_t delta, typename BaseMap_t::iterator start, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
PairValue_t cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::increment_and_get_max ( Key_t  key_begin,
Key_t  key_end 
)
inline

Increments by 1 the specified counters and returns the maximum.

Parameters
key_beginkey of the first counter to be increased
key_endkey of the first counter not to be increased
Returns
pair with an iterator to the largest counter and its value
See also
increment(Key_t, Key_t)

This method works like the corresponding increment() method, and in addition it returns the location of the counter with the largest count (after the increase). The return value consist of a pair: the second is the largest counter value in the range after the increase, the first member is the constant iterator pointing to the first (lowest key) counter with that (get its key with const_iterator::key() method).

If no maximum is found, the maximum in the return value is equal to current_max, while the iterator points to the end of the map (end()). Note that if all the counters are at the minimum possible value, no maximum will be returned.

Definition at line 366 of file HoughBaseAlg.h.

Referenced by cluster::HoughTransform::DoAddPointReturnMax().

367  {
368  return unchecked_add_range_max(key_begin, key_end, +1);
369  }
PairValue_t unchecked_add_range_max(Key_t key_begin, Key_t key_end, SubCounter_t delta, typename BaseMap_t::iterator start, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
PairValue_t cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::increment_and_get_max ( Key_t  key_begin,
Key_t  key_end,
SubCounter_t  current_max 
)
inline

Increments by 1 the specified counters and returns the maximum.

Parameters
key_beginkey of the first counter to be increased
key_endkey of the first counter not to be increased
current_maxonly counters larger than this will be considered
Returns
pair with an iterator to the largest counter and its value
See also
increment(Key_t, Key_t), increment_and_get_max(Key_t, Key_t)

This method works like increment_and_get_max() method, except that it does not update the maximum if it's not (strictly) larger than current_max. If no such a maximum is found, the maximum in the return value is equal to current_max, while the iterator points to the end of the map (end()).

Definition at line 385 of file HoughBaseAlg.h.

386  {
387  return unchecked_add_range_max(key_begin, key_end, +1, current_max);
388  }
PairValue_t unchecked_add_range_max(Key_t key_begin, Key_t key_end, SubCounter_t delta, typename BaseMap_t::iterator start, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
template<typename K , typename C , size_t S, typename A , unsigned int SUB>
template<typename OALLOC >
bool lar::CountersMap< K, C, S, A, SUB >::is_equal ( const std::map< Key_t, SubCounter_t, std::less< Key_t >, OALLOC > &  to,
Key_t first_difference 
) const
inherited

Returns whether the counters in this map are equivalent to another.

Parameters
toa STL map
first_differencekey of the first difference
Returns
whether the counters are equivalent

The maps are considered equal if all keys in each are present in the other, and their counters have the same value, with one exception: counters in CountersMap can not to exist in the other map, but only if their count is 0 (these should be plenty of them since counters are created in blocks).

If there is a key in one map but not in the other, first_difference stores that key; if a counter is present in both maps but with a different count, first_difference reports the key of that counter. If no difference is found, first_difference is left untouched.

Definition at line 540 of file CountersMap.h.

543  {
544  // this function is not optimised
545  using CompMap_t = const std::map<Key_t, SubCounter_t, std::less<Key_t>, OALLOC>;
546  typename CompMap_t::const_iterator to_iter = to.begin(), to_end = to.end();
547  for (const typename const_iterator::value_type& p : *this) {
548 
549  if (to_iter != to_end) { // we have still counters to find
550  // if counter is already beyond the next non-empty one froml STL map,
551  // then we are missing some
552  if (p.first > to_iter->first) {
553  first_difference = to_iter->first;
554  return false;
555  }
556  // while (p.first > to_iter->first) {
557  // ++nMissingKeys;
558  // std::cout << "ERROR missing key " << to_iter->first << std::endl;
559  // if (++to_iter == to_end) break;
560  // } // while
561  // } // if
562  //
563  // if (to_iter != to_end) { // we have still counters to find
564  if (p.first == to_iter->first) {
565  // if the counter is in SLT map, the two counts must match
566  // std::cout << " " << p.first << " " << p.second << std::endl;
567  if (to_iter->second != p.second) {
568  // std::cout << "ERROR wrong counter value " << p.second
569  // << ", expected " << to_iter->second << std::endl;
570  // ++nMismatchValue;
571  first_difference = to_iter->first;
572  return false;
573  }
574  ++to_iter; // done with it
575  }
576  else if (p.first < to_iter->first) {
577  // if the counter is not in STL map, then it must be 0
578  if (p.second != 0) {
579  // ++nExtraKeys;
580  // std::cout << "ERROR extra key " << p.first << " (" << p.second << ")"
581  // << std::endl;
582  first_difference = p.first;
583  return false;
584  }
585  // else {
586  // std::cout << " " << p.first << " " << p.second << " (not in STL)"
587  // << std::endl;
588  // }
589  }
590  }
591  else { // if we are at the end of compared map
592  // no more keys in STL map
593  if (p.second != 0) {
594  // ++nExtraKeys;
595  // std::cout << "ERROR extra key " << p.first << " (" << p.second << ")"
596  // << std::endl;
597  first_difference = p.first;
598  return false;
599  }
600  }
601  } // for element in map
602 
603  return true;
604  } // CountersMap<>::is_equal()
intermediate_table::const_iterator const_iterator
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
template<typename OALLOC >
bool lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::is_equal ( const std::map< Key_t, SubCounter_t, std::less< Key_t >, OALLOC > &  to) const
inlineinherited

Returns whether the counters in this map are equivalent to another.

Parameters
toa STL map
Returns
whether the counters are equivalent

Definition at line 263 of file CountersMap.h.

264  {
265  Key_t dummy;
266  return is_equal(to, dummy);
267  }
KEY Key_t
type of counter key in the map
Definition: CountersMap.h:138
bool is_equal(const std::map< Key_t, SubCounter_t, std::less< Key_t >, OALLOC > &to, Key_t &first_difference) const
Returns whether the counters in this map are equivalent to another.
Definition: CountersMap.h:540
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
static const_iterator lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::make_const_iterator ( typename BaseMap_t::const_iterator  it,
size_t  ix 
)
inlinestaticprotectedinherited

Creates a const_iterator (useful in derived classes)

Definition at line 374 of file CountersMap.h.

375  {
376  return {it, ix};
377  }
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
std::make_unsigned<Key_t>::type lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::n_counters ( ) const
inlineinherited

Returns the number of allocated counters.

Definition at line 231 of file CountersMap.h.

232  {
233  return counter_map.size() * NSubcounters;
234  }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
static constexpr size_t NSubcounters
Number of subcounters in one counter block.
Definition: CountersMap.h:149
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
SubCounter_t lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::operator[] ( Key_t  key) const
inlineinherited

Read-only access to an element; returns 0 if no counter is present.

Definition at line 187 of file CountersMap.h.

References util::begin(), util::end(), and value.

187 { return GetSubCounter(key); }
SubCounter_t GetSubCounter(CounterKey_t key) const
Returns the value of the subcounter at the specified split key.
Definition: CountersMap.h:365
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
SubCounter_t cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::set ( Key_t  key,
SubCounter_t  value 
)
inline

Sets the specified counter to a count value.

Parameters
keykey of the counter to be set
valuethe count value
Returns
new value of the counter

Definition at line 309 of file HoughBaseAlg.h.

References value.

309 { return Base_t::set(key, value); }
double value
Definition: spectrum.C:18
SubCounter_t set(Key_t key, SubCounter_t value)
Sets the specified counter to a count.
Definition: CountersMap.h:503
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = std::allocator<std::pair<KEY, std::array<COUNTER, SIZE>>>, unsigned int SUBCOUNTERS = 1>
SubCounter_t cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::set ( Key_t  key_begin,
Key_t  key_end,
SubCounter_t  value 
)
inline

Sets the specified range of counters to a count value.

Parameters
key_beginkey of the first counter to be set
key_endkey of the first counter not to be set
valuethe count value
Returns
new value of all the counters
See also
increment(), decrement(), increment_and_get_max()

Definition at line 333 of file HoughBaseAlg.h.

References value.

334  {
335  return unchecked_set_range(key_begin, key_end, value);
336  }
double value
Definition: spectrum.C:18
SubCounter_t unchecked_set_range(Key_t key_begin, Key_t key_end, SubCounter_t value, typename BaseMap_t::iterator start)
template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
static CounterKey_t lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::SplitKey ( Key_t  key)
inlinestaticprotectedinherited

Returns a split key corresponding to the specified key.

Definition at line 371 of file CountersMap.h.

371 { return key; }
template<typename K , typename C , size_t S, typename A , unsigned int SC>
cluster::HoughTransformCounters< K, C, S, A, SC >::PairValue_t cluster::HoughTransformCounters< K, C, S, A, SC >::unchecked_add_range_max ( Key_t  key_begin,
Key_t  key_end,
SubCounter_t  delta,
typename BaseMap_t::iterator  start,
SubCounter_t  min_max = std::numeric_limits<SubCounter_t>::min() 
)
private

Definition at line 202 of file HoughBaseAlg.cxx.

References util::end(), art::left(), n, and value.

209 {
211  if (key_begin > key_end) return max;
212  CounterKey_t key(key_begin);
213  size_t left = key_end - key_begin;
214  while (true) {
215  if ((iIP == Base_t::counter_map.end()) || (iIP->first != key.block)) {
216  // we don't have that block yet
217  iIP = Base_t::counter_map.insert(iIP, {key.block, {}});
218  } // if need to add a block
219  CounterBlock_t& block = iIP->second;
220  size_t n = std::min(left, Base_t::NCounters - key.counter);
221  left -= n;
222  while (n--) {
223  SubCounter_t value = (block[key.counter] += delta);
224  if (value > max.second) { max = {Base_t::make_const_iterator(iIP, key.counter), value}; }
225  ++(key.counter);
226  } // for key.counter
227  if (left <= 0) break;
228  key.next_block();
229  ++iIP;
230  } // while
231  return max;
232 } // cluster::HoughTransformCounters<>::unchecked_add_range_max()
typename Base_t::SubCounter_t SubCounter_t
Definition: HoughBaseAlg.h:290
const_iterator end() const
Returns an iterator past-the-end of the counters.
Definition: CountersMap.h:532
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:433
std::pair< const_iterator, SubCounter_t > PairValue_t
Pair identifying a counter and its current value.
Definition: HoughBaseAlg.h:295
static const_iterator make_const_iterator(typename BaseMap_t::const_iterator it, size_t ix)
Creates a const_iterator (useful in derived classes)
Definition: CountersMap.h:374
double value
Definition: spectrum.C:18
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
typename Base_t::CounterBlock_t CounterBlock_t
Definition: HoughBaseAlg.h:291
Char_t n[5]
static constexpr size_t NCounters
Number of counters in one counter block.
Definition: CountersMap.h:146
template<typename K , typename C , size_t S, typename A , unsigned int SC>
cluster::HoughTransformCounters< K, C, S, A, SC >::PairValue_t cluster::HoughTransformCounters< K, C, S, A, SC >::unchecked_add_range_max ( Key_t  key_begin,
Key_t  key_end,
SubCounter_t  delta,
SubCounter_t  min_max = std::numeric_limits<SubCounter_t>::min() 
)
inlineprivate

Definition at line 236 of file HoughBaseAlg.cxx.

242 {
243  return unchecked_add_range_max(key_begin,
244  key_end,
245  delta,
246  Base_t::counter_map.lower_bound(CounterKey_t(key_begin).block),
247  min_max);
248 } // cluster::HoughTransformCounters<>::unchecked_add_range_max(no hint)
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:433
PairValue_t unchecked_add_range_max(Key_t key_begin, Key_t key_end, SubCounter_t delta, typename BaseMap_t::iterator start, SubCounter_t min_max=std::numeric_limits< SubCounter_t >::min())
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
template<typename K , typename C , size_t S, typename A , unsigned int SC>
cluster::HoughTransformCounters< K, C, S, A, SC >::SubCounter_t cluster::HoughTransformCounters< K, C, S, A, SC >::unchecked_set_range ( Key_t  key_begin,
Key_t  key_end,
SubCounter_t  value,
typename BaseMap_t::iterator  start 
)
private

Definition at line 166 of file HoughBaseAlg.cxx.

References util::end(), art::left(), n, and value.

171 {
172  if (key_begin > key_end) return value;
173  CounterKey_t key(key_begin);
174  size_t left = key_end - key_begin;
175  while (true) {
176  if ((iIP == Base_t::counter_map.end()) || (iIP->first != key.block)) {
177  // we don't have that block yet
178  iIP = Base_t::counter_map.insert(iIP, {key.block, {}});
179  } // if need to add a block
180  CounterBlock_t& block = iIP->second;
181  size_t n = std::min(left, Base_t::NCounters - key.counter);
182  block.fill(key.counter, n, value);
183  if (left -= n <= 0) break;
184  key.next_block();
185  ++iIP;
186  } // while
187  return value;
188 } // cluster::HoughTransformCounters<>::unchecked_set_range()
const_iterator end() const
Returns an iterator past-the-end of the counters.
Definition: CountersMap.h:532
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:433
double value
Definition: spectrum.C:18
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
typename Base_t::CounterBlock_t CounterBlock_t
Definition: HoughBaseAlg.h:291
Char_t n[5]
static constexpr size_t NCounters
Number of counters in one counter block.
Definition: CountersMap.h:146
template<typename K , typename C , size_t S, typename A , unsigned int SC>
cluster::HoughTransformCounters< K, C, S, A, SC >::SubCounter_t cluster::HoughTransformCounters< K, C, S, A, SC >::unchecked_set_range ( Key_t  key_begin,
Key_t  key_end,
SubCounter_t  value 
)
inlineprivate

Definition at line 192 of file HoughBaseAlg.cxx.

195 {
196  return unchecked_set_range(
197  key_begin, key_end, value, Base_t::counter_map.lower_bound(CounterKey_t(key_begin).block));
198 } // cluster::HoughTransformCounters<>::unchecked_set_range(no hint)
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:433
double value
Definition: spectrum.C:18
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:358
SubCounter_t unchecked_set_range(Key_t key_begin, Key_t key_end, SubCounter_t value, typename BaseMap_t::iterator start)

Member Data Documentation

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
BaseMap_t lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::counter_map
protectedinherited

the actual data structure for counters

Definition at line 358 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
constexpr size_t lar::CountersMap< K, C, S, A, SUB >::NCounters = Traits_t::NCounters
staticinherited

Number of counters in one counter block.

Definition at line 146 of file CountersMap.h.

template<typename KEY, typename COUNTER, size_t SIZE, typename ALLOC = typename details::CountersMapTraits<KEY, COUNTER, SIZE>::DefaultAllocator_t, unsigned int SUBCOUNTERS = 1>
constexpr size_t lar::CountersMap< K, C, S, A, SUB >::NSubcounters = NCounters * SUBCOUNTERS
staticinherited

Number of subcounters in one counter block.

Definition at line 149 of file CountersMap.h.


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