LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 293 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 306 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 184 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 302 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 305 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 290 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 310 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 148 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 309 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 292 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 455 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 300 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 307 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 183 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 313 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 308 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 188 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 316 of file HoughBaseAlg.h.

316 : Base_t() {}
lar::CountersMap< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS > Base_t
Base class.
Definition: HoughBaseAlg.h:302
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 319 of file HoughBaseAlg.h.

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

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 511 of file CountersMap.h.

512  { return const_iterator{ counter_map.begin(), 0 }; }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
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 343 of file HoughBaseAlg.h.

Referenced by cluster::HoughTransform::DoAddPointReturnMax(), and cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::increment().

343 { return Base_t::decrement(key); }
SubCounter_t decrement(Key_t key)
Decrements by 1 the specified counter.
Definition: CountersMap.h:505
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 92 of file HoughBaseAlg.cxx.

References cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::get_max(), and max.

93 {
95  (key_begin, key_end, -1, std::numeric_limits<SubCounter_t>::max());
96 } // 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())
Int_t max
Definition: plot.C:27
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 245 of file CountersMap.h.

245 { return counter_map.empty(); }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
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 516 of file CountersMap.h.

517  { return const_iterator{ counter_map.end(), 0 }; }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
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 102 of file HoughBaseAlg.cxx.

References evd::details::end(), and max.

103 {
105  { Base_t::make_const_iterator(Base_t::counter_map.end(), 0), current_max };
106 
107  typename BaseMap_t::const_iterator iCBlock = Base_t::counter_map.begin(),
108  cend = Base_t::counter_map.end();
109  while (iCBlock != cend) {
110  const CounterBlock_t& block = iCBlock->second;
111  for (size_t index = 0; index < block.size(); ++index) {
112  if (block[index] > max.second)
113  max = { Base_t::make_const_iterator(iCBlock, index), block[index] };
114  ++iCBlock;
115  } // for elements in this block
116  } // while blocks
117  return max;
118 } // cluster::HoughTransformCounters<>::get_max(SubCounter_t)
const_iterator end() const
Returns an iterator past-the-end of the counters.
Definition: CountersMap.h:516
std::pair< const_iterator, SubCounter_t > PairValue_t
Pair identifying a counter and its current value.
Definition: HoughBaseAlg.h:313
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:379
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
typename Base_t::CounterBlock_t CounterBlock_t
Definition: HoughBaseAlg.h:309
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 123 of file HoughBaseAlg.cxx.

References max.

Referenced by cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::decrement().

Int_t max
Definition: plot.C:27
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 592 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.

593  {
594  typename BaseMap_t::const_iterator iBlock = counter_map.find(key.block);
595  return (iBlock == counter_map.end())? 0: iBlock->second[key.counter];
596  } // CountersMap<>::GetCounter() const
intermediate_table::const_iterator const_iterator
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
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 601 of file CountersMap.h.

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

602  { return counter_map[key.block][key.counter]; }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
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 367 of file CountersMap.h.

368  { return GetCounter(key); }
Counter_t GetCounter(CounterKey_t key) const
Returns the value of the counter at the specified split key.
Definition: CountersMap.h:592
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 336 of file HoughBaseAlg.h.

Referenced by sqr().

336 { return Base_t::increment(key); }
SubCounter_t increment(Key_t key)
Increments by 1 the specified counter.
Definition: CountersMap.h:500
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 83 of file HoughBaseAlg.cxx.

References cluster::HoughTransformCounters< KEY, COUNTER, SIZE, ALLOC, SUBCOUNTERS >::decrement(), and max.

84 {
86  (key_begin, key_end, +1, std::numeric_limits<SubCounter_t>::max());
87 } // 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())
Int_t max
Definition: plot.C:27
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 386 of file HoughBaseAlg.h.

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

387  { return unchecked_add_range_max(key_begin, key_end, +1); }
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 405 of file HoughBaseAlg.h.

406  { return unchecked_add_range_max(key_begin, key_end, +1, current_max); }
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 522 of file CountersMap.h.

525  {
526  // this function is not optimised
527  using CompMap_t
528  = const std::map<Key_t, SubCounter_t, std::less<Key_t>, OALLOC>;
529  typename CompMap_t::const_iterator to_iter = to.begin(), to_end = to.end();
530  for (const typename const_iterator::value_type& p: *this) {
531 
532  if (to_iter != to_end) { // we have still counters to find
533  // if counter is already beyond the next non-empty one froml STL map,
534  // then we are missing some
535  if (p.first > to_iter->first) {
536  first_difference = to_iter->first;
537  return false;
538  }
539  // while (p.first > to_iter->first) {
540  // ++nMissingKeys;
541  // std::cout << "ERROR missing key " << to_iter->first << std::endl;
542  // if (++to_iter == to_end) break;
543  // } // while
544  // } // if
545  //
546  // if (to_iter != to_end) { // we have still counters to find
547  if (p.first == to_iter->first) {
548  // if the counter is in SLT map, the two counts must match
549  // std::cout << " " << p.first << " " << p.second << std::endl;
550  if (to_iter->second != p.second) {
551  // std::cout << "ERROR wrong counter value " << p.second
552  // << ", expected " << to_iter->second << std::endl;
553  // ++nMismatchValue;
554  first_difference = to_iter->first;
555  return false;
556  }
557  ++to_iter; // done with it
558  }
559  else if (p.first < to_iter->first) {
560  // if the counter is not in STL map, then it must be 0
561  if (p.second != 0) {
562  // ++nExtraKeys;
563  // std::cout << "ERROR extra key " << p.first << " (" << p.second << ")"
564  // << std::endl;
565  first_difference = p.first;
566  return false;
567  }
568  // else {
569  // std::cout << " " << p.first << " " << p.second << " (not in STL)"
570  // << std::endl;
571  // }
572  }
573  }
574  else { // if we are at the end of compared map
575  // no more keys in STL map
576  if (p.second != 0) {
577  // ++nExtraKeys;
578  // std::cout << "ERROR extra key " << p.first << " (" << p.second << ")"
579  // << std::endl;
580  first_difference = p.first;
581  return false;
582  }
583  }
584  } // for element in map
585 
586  return true;
587  } // CountersMap<>::is_equal()
typename CounterMap_t::value_type value_type
value type: pair
Definition: CountersMap.h:441
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 284 of file CountersMap.h.

285  { Key_t dummy; return is_equal(to, dummy); }
KEY Key_t
type of counter key in the map
Definition: CountersMap.h:147
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:522
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 379 of file CountersMap.h.

380  { return { it, ix }; }
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 249 of file CountersMap.h.

250  { return counter_map.size() * NSubcounters; }
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
static constexpr size_t NSubcounters
Number of subcounters in one counter block.
Definition: CountersMap.h:159
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 202 of file CountersMap.h.

References evd::details::begin(), evd::details::end(), and fhicl::detail::atom::value().

202 { return GetSubCounter(key); }
SubCounter_t GetSubCounter(CounterKey_t key) const
Returns the value of the subcounter at the specified split key.
Definition: CountersMap.h:367
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 328 of file HoughBaseAlg.h.

References fhicl::detail::atom::value().

329  { return Base_t::set(key, value); }
std::string value(boost::any const &)
SubCounter_t set(Key_t key, SubCounter_t value)
Sets the specified counter to a count.
Definition: CountersMap.h:495
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 354 of file HoughBaseAlg.h.

References fhicl::detail::atom::value().

355  { return unchecked_set_range(key_begin, key_end, value); }
std::string value(boost::any const &)
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 375 of file CountersMap.h.

375 { 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 164 of file HoughBaseAlg.cxx.

References evd::details::end(), art::left(), max, min, and n.

168  {
171  if (key_begin > key_end) return max;
172  CounterKey_t key(key_begin);
173  size_t left = key_end - key_begin;
174  while (true) {
175  if ((iIP == Base_t::counter_map.end()) || (iIP->first != key.block)) {
176  // we don't have that block yet
177  iIP = Base_t::counter_map.insert(iIP, { key.block, {}});
178  } // if need to add a block
179  CounterBlock_t& block = iIP->second;
180  size_t n = std::min(left, Base_t::NCounters - key.counter);
181  left -= n;
182  while (n--) {
183  SubCounter_t value = (block[key.counter] += delta);
184  if (value > max.second) {
185  max = { Base_t::make_const_iterator(iIP, key.counter), value };
186  }
187  ++(key.counter);
188  } // for key.counter
189  if (left <= 0) break;
190  key.next_block();
191  ++iIP;
192  } // while
193  return max;
194 } // cluster::HoughTransformCounters<>::unchecked_add_range_max()
typename Base_t::SubCounter_t SubCounter_t
Definition: HoughBaseAlg.h:308
const_iterator end() const
Returns an iterator past-the-end of the counters.
Definition: CountersMap.h:516
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:455
std::pair< const_iterator, SubCounter_t > PairValue_t
Pair identifying a counter and its current value.
Definition: HoughBaseAlg.h:313
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:379
Int_t max
Definition: plot.C:27
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
typename Base_t::CounterBlock_t CounterBlock_t
Definition: HoughBaseAlg.h:309
std::string value(boost::any const &)
Int_t min
Definition: plot.C:26
Char_t n[5]
static constexpr size_t NCounters
Number of counters in one counter block.
Definition: CountersMap.h:156
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 199 of file HoughBaseAlg.cxx.

202  {
203  return unchecked_add_range_max(key_begin, key_end, delta,
204  Base_t::counter_map.lower_bound(CounterKey_t(key_begin).block), min_max);
205 } // cluster::HoughTransformCounters<>::unchecked_add_range_max(no hint)
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:455
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:359
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 129 of file HoughBaseAlg.cxx.

References evd::details::end(), art::left(), min, n, and fhicl::detail::atom::value().

132  {
133  if (key_begin > key_end) return value;
134  CounterKey_t key(key_begin);
135  size_t left = key_end - key_begin;
136  while (true) {
137  if ((iIP == Base_t::counter_map.end()) || (iIP->first != key.block)) {
138  // we don't have that block yet
139  iIP = Base_t::counter_map.insert(iIP, { key.block, {}});
140  } // if need to add a block
141  CounterBlock_t& block = iIP->second;
142  size_t n = std::min(left, Base_t::NCounters - key.counter);
143  block.fill(key.counter, n, value);
144  if (left -= n <= 0) break;
145  key.next_block();
146  ++iIP;
147  } // while
148  return value;
149 } // cluster::HoughTransformCounters<>::unchecked_set_range()
const_iterator end() const
Returns an iterator past-the-end of the counters.
Definition: CountersMap.h:516
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:455
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
typename Base_t::CounterBlock_t CounterBlock_t
Definition: HoughBaseAlg.h:309
std::string value(boost::any const &)
Int_t min
Definition: plot.C:26
Char_t n[5]
static constexpr size_t NCounters
Number of counters in one counter block.
Definition: CountersMap.h:156
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 155 of file HoughBaseAlg.cxx.

156 {
157  return unchecked_set_range(key_begin, key_end, value,
158  Base_t::counter_map.lower_bound(CounterKey_t(key_begin).block));
159 } // cluster::HoughTransformCounters<>::unchecked_set_range(no hint)
typename Base_t::CounterKey_t CounterKey_t
Definition: HoughBaseAlg.h:455
BaseMap_t counter_map
the actual data structure for counters
Definition: CountersMap.h:359
std::string value(boost::any const &)
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 359 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 156 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 159 of file CountersMap.h.


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